wirybeaver commented on code in PR #15958: URL: https://github.com/apache/pinot/pull/15958#discussion_r2140170305
########## pinot-query-planner/src/main/java/org/apache/pinot/calcite/rel/rules/PinotRuleUtils.java: ########## @@ -122,4 +135,129 @@ public static String extractFunctionName(RexCall function) { SqlKind funcSqlKind = function.getOperator().getKind(); return funcSqlKind == SqlKind.OTHER_FUNCTION ? function.getOperator().getName() : funcSqlKind.name(); } + + public static class WindowUtils { + // Supported window functions + // OTHER_FUNCTION supported are: BOOL_AND, BOOL_OR + private static final EnumSet<SqlKind> SUPPORTED_WINDOW_FUNCTION_KIND = + EnumSet.of(SqlKind.SUM, SqlKind.SUM0, SqlKind.MIN, SqlKind.MAX, SqlKind.COUNT, SqlKind.ROW_NUMBER, SqlKind.RANK, + SqlKind.DENSE_RANK, SqlKind.NTILE, SqlKind.LAG, SqlKind.LEAD, SqlKind.FIRST_VALUE, SqlKind.LAST_VALUE, + SqlKind.OTHER_FUNCTION); + + public static void validateWindows(Window window) { + int numGroups = window.groups.size(); + // For Phase 1 we only handle single window groups + Preconditions.checkState(numGroups == 1, + String.format("Currently only 1 window group is supported, query has %d groups", numGroups)); + + // Validate that only supported window aggregation functions are present + Window.Group windowGroup = window.groups.get(0); + validateWindowAggCallsSupported(windowGroup); + + // Validate the frame + validateWindowFrames(windowGroup); + } + + /** + * Replaces the reference to literal arguments in the window group with the actual literal values. + * NOTE: {@link Window} has a field called "constants" which contains the literal values. If the input reference is + * beyond the window input size, it is a reference to the constants. + */ + public static Window.Group updateLiteralArgumentsInWindowGroup(Window window) { Review Comment: Could you add more comments about how does RexInputRef(x) find the element in constant list with more details? That's what I get by using copilot. <h3 style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.25em; font-weight: 600; line-height: 1.25; color: rgb(31, 35, 40); font-family: -apple-system, "system-ui", "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="box-sizing: border-box;">1.<span> </span></span><strong style="box-sizing: border-box; font-weight: 600;"><span style="box-sizing: border-box;">Understanding<span> </span></span><span style="box-sizing: border-box;">the<span> </span></span><spa n style="box-sizing: border-box;">Inputs</span></strong></h3><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: -apple-system, "system-ui", "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="box-sizing: border-box;">When<span> </span></span><span style="box-sizing: border-box;">Calcite<span> </span></span><span style="box-sizing: border-box;">constructs<span> </span></span><span style="box-sizing : border-box;">a<span> </span></span><code node="[object Object]" style="box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 11.9px; padding: 0.2em 0.4em; margin: 0px; white-space: break-spaces; background-color: rgba(129, 139, 152, 0.12); border-radius: 6px;"><span style="box-sizing: border-box;">Window</span></code><span> </span><span style="box-sizing: border-box;">relational<span> </span></span><span style="box-sizing: border-box;">node,<span> </span></span><span style="box-sizing: border-box;">it<span> </span></span><span style="box-sizing: border-box;">conceptually<span> </span></span><span style="box-sizing: border-box;">sees<span> </span></span><span style="box-sizing: border-box;">the<span> </span></span><span style="box-sizing: border-box;">input<span> </span></span><span style="box-sizing: border-box;">as:</span></p><ul style="box-sizing: border-box; padding-le ft: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: -apple-system, "system-ui", "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><li style="box-sizing: border-box;"><span style="box-sizing: border-box;">All<span> </span></span><span style="box-sizing: border-box;">columns<span> </span></span><span style="box-sizing: border-box;">from<span> </span></span><span style="box-sizing: border-box;">the<span> </span></span><span style="box- sizing: border-box;">input<span> </span></span><span style="box-sizing: border-box;">relation<span> </span></span><span style="box-sizing: border-box;">(e.g.,<span> </span></span><span style="box-sizing: border-box;">your<span> </span></span><span style="box-sizing: border-box;">table<span> </span></span><span style="box-sizing: border-box;">columns)</span></li><li style="box-sizing: border-box; margin-top: 0.25em;"><span style="box-sizing: border-box;">Followed<span> </span></span><span style="box-sizing: border-box;">by<span> </span></span><span style="box-sizing: border-box;">any<span> </span></span><span style="box-sizing: border-box;">literal<span> </span></span><span style="box-sizing: border-box;">constants<span> </span></span><span style="box-sizing: border-box;">needed<span> </span></span><span style="box-sizing: border-box;">by<span> </span></span><span style="box-sizing: border-box;">window<span> </span></span><span style="box-sizing: border-box;">functions<s pan> </span></span><span style="box-sizing: border-box;">(these<span> </span></span><span style="box-sizing: border-box;">are<span> </span></span><span style="box-sizing: border-box;">placed<span> </span></span><span style="box-sizing: border-box;">in<span> </span></span><span style="box-sizing: border-box;">the<span> </span></span><code node="[object Object]" style="box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 11.9px; padding: 0.2em 0.4em; margin: 0px; white-space: break-spaces; background-color: rgba(129, 139, 152, 0.12); border-radius: 6px;"><span style="box-sizing: border-box;">constants</span></code><span> </span><span style="box-sizing: border-box;">list<span> </span></span><span style="box-sizing: border-box;">in<span> </span></span><span style="box-sizing: border-box;">the<span> </span></span><span style="box-sizing: border-box;">Window<span> </span></spa n><span style="box-sizing: border-box;">node)</span></li></ul><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: -apple-system, "system-ui", "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="box-sizing: border-box;">So,<span> </span></span><span style="box-sizing: border-box;">if<span> </span></span><span style="box-sizing: border-box;">your<span> </span></span><span style="box-sizing: border-bo x;">input<span> </span></span><span style="box-sizing: border-box;">row<span> </span></span><span style="box-sizing: border-box;">has<span> </span></span><span style="box-sizing: border-box;">N<span> </span></span><span style="box-sizing: border-box;">columns,<span> </span></span><span style="box-sizing: border-box;">and<span> </span></span><span style="box-sizing: border-box;">your<span> </span></span><span style="box-sizing: border-box;">window<span> </span></span><span style="box-sizing: border-box;">function<span> </span></span><span style="box-sizing: border-box;">needs<span> </span></span><span style="box-sizing: border-box;">K<span> </span></span><span style="box-sizing: border-box;">constants,<span> </span></span><span style="box-sizing: border-box;">the<span> </span></span><span style="box-sizing: border-box;">total<span> </span></span><span style="box-sizing: border-box;">"input"<span> </span></span><span style="box-sizing: border-box;">to<span> </span></sp an><span style="box-sizing: border-box;">the<span> </span></span><span style="box-sizing: border-box;">Window<span> </span></span><span style="box-sizing: border-box;">node<span> </span></span><span style="box-sizing: border-box;">is<span> </span></span><span style="box-sizing: border-box;">N<span> </span></span><span style="box-sizing: border-box;">+<span> </span></span><span style="box-sizing: border-box;">K.</span></p><hr style="box-sizing: border-box; height: 0.25em; overflow: hidden; margin: 24px 0px; background: rgb(209, 217, 224); border: 0px; padding: 0px; color: rgb(31, 35, 40); font-family: -apple-system, "system-ui", "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; wi dows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><h3 style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.25em; font-weight: 600; line-height: 1.25; color: rgb(31, 35, 40); font-family: -apple-system, "system-ui", "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="box-sizing: border-box;">2.<span> </span></span><strong style="box -sizing: border-box; font-weight: 600;"><span style="box-sizing: border-box;">How<span> </span></span><span style="box-sizing: border-box;">RexInputRef<span> </span></span><span style="box-sizing: border-box;">Works<span> </span></span><span style="box-sizing: border-box;">in<span> </span></span><span style="box-sizing: border-box;">This<span> </span></span><span style="box-sizing: border-box;">Context</span></strong></h3><ul style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: -apple-system, "system-ui", "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><li style="box-sizing: border-box;"><code node="[object Object]" style="box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 11.9px; padding: 0.2em 0.4em; margin: 0px; white-space: break-spaces; background-color: rgba(129, 139, 152, 0.12); border-radius: 6px;"><span style="box-sizing: border-box;">RexInputRef(i)</span></code><span> </span><span style="box-sizing: border-box;">refers<span> </span></span><span style="box-sizing: border-box;">to<span> </span></span><span style="box-sizing: border-box;">the<span> </span></span><span style="box-sizing: border-box;">i-th<span> </span></span><span style="box-sizing: border-box;">field<span> </span></span><span style="box-sizing: border-box;">in<span> </span></span><spa n style="box-sizing: border-box;">the<span> </span></span><span style="box-sizing: border-box;">Window<span> </span></span><span style="box-sizing: border-box;">node's<span> </span></span><span style="box-sizing: border-box;">input.</span></li><li style="box-sizing: border-box; margin-top: 0.25em;"><span style="box-sizing: border-box;">If<span> </span></span><code node="[object Object]" style="box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 11.9px; padding: 0.2em 0.4em; margin: 0px; white-space: break-spaces; background-color: rgba(129, 139, 152, 0.12); border-radius: 6px;"><span style="box-sizing: border-box;">i </span><span style="box-sizing: border-box;">< </span><span style="box-sizing: border-box;">N</span></code><span style="box-sizing: border-box;">,<span> </span></span><span style="box-sizing: border-box;">it<span> </span></span><span style="box-sizing: border -box;">points<span> </span></span><span style="box-sizing: border-box;">to<span> </span></span><span style="box-sizing: border-box;">the<span> </span></span><span style="box-sizing: border-box;">i-th<span> </span></span><span style="box-sizing: border-box;">field<span> </span></span><span style="box-sizing: border-box;">of<span> </span></span><span style="box-sizing: border-box;">the<span> </span></span><span style="box-sizing: border-box;">original<span> </span></span><span style="box-sizing: border-box;">input<span> </span></span><span style="box-sizing: border-box;">row<span> </span></span><span style="box-sizing: border-box;">(e.g.,<span> </span></span><span style="box-sizing: border-box;">a<span> </span></span><span style="box-sizing: border-box;">table<span> </span></span><span style="box-sizing: border-box;">column).</span></li><li style="box-sizing: border-box; margin-top: 0.25em;"><span style="box-sizing: border-box;">If<span> </span></span><code node="[object Object]" style="box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 11.9px; padding: 0.2em 0.4em; margin: 0px; white-space: break-spaces; background-color: rgba(129, 139, 152, 0.12); border-radius: 6px;"><span style="box-sizing: border-box;">i </span><span style="box-sizing: border-box;">>= </span><span style="box-sizing: border-box;">N</span></code><span style="box-sizing: border-box;">,<span> </span></span><span style="box-sizing: border-box;">it<span> </span></span><span style="box-sizing: border-box;">points<span> </span></span><span style="box-sizing: border-box;">to<span> </span></span><span style="box-sizing: border-box;">the<span> </span></span><span style="box-sizing: border-box;">(i<span> </span></span><span style="box-sizing: border-box;">-<span> </span></span><span style="box-sizing: border-box;">N)-th<span> </span></span><span style="box-sizing: border-box ;">entry<span> </span></span><span style="box-sizing: border-box;">in<span> </span></span><span style="box-sizing: border-box;">the<span> </span></span><code node="[object Object]" style="box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 11.9px; padding: 0.2em 0.4em; margin: 0px; white-space: break-spaces; background-color: rgba(129, 139, 152, 0.12); border-radius: 6px;"><span style="box-sizing: border-box;">constants</span></code><span> </span><span style="box-sizing: border-box;">list.</span></li></ul><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: -apple-system, "system-ui", "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; f ont-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><strong style="box-sizing: border-box; font-weight: 600;"><span style="box-sizing: border-box;">Example:</span></strong></p><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: -apple-system, "system-ui", "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke -width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="box-sizing: border-box;">Suppose<span> </span></span><span style="box-sizing: border-box;">your<span> </span></span><span style="box-sizing: border-box;">table<span> </span></span><span style="box-sizing: border-box;">has<span> </span></span><span style="box-sizing: border-box;">2<span> </span></span><span style="box-sizing: border-box;">columns:<span> </span></span><code node="[object Object]" style="box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 11.9px; padding: 0.2em 0.4em; margin: 0px; white-space: break-spaces; background-color: rgba(129, 139, 152, 0.12); border-radius: 6px;"><span style="box-sizing: border-box;">employee_id</span></code><span style="box-sizing: border-box;">,<span> </span></span><code node="[object Object]" style="box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 11.9px; padding: 0.2em 0.4em; margin: 0px; white-space: break-spaces; background-color: rgba(129, 139, 152, 0.12); border-radius: 6px;"><span style="box-sizing: border-box;">salary</span></code><span style="box-sizing: border-box;">.</span><br style="box-sizing: border-box;"><span style="box-sizing: border-box;">Suppose<span> </span></span><span style="box-sizing: border-box;">your<span> </span></span><span style="box-sizing: border-box;">window<span> </span></span><span style="box-sizing: border-box;">function<span> </span></span><span style="box-sizing: border-box;">is:</span></p><figure class="CodeBlock-module__container--BRsgk CodeBlock-module__assistive--vRZZ9" aria-labelledby=":r16e:" style="box-sizing: border-box; display: block; margin: 0px 0px 16px; --header-height: 3rem; color: rgb(31, 35, 40); font-family: -apple-system, "system-ui", "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="CodeBlock-module__header--RMUQr" style="box-sizing: border-box; align-items: center; background-color: rgb(246, 248, 250); border-color: rgba(209, 217, 224, 0.7); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; border-radius: 12px 12px 0px 0px; color: rgb(89, 99, 110); display: flex; gap: 4px; height: 48 px; padding-left: 16px; padding-right: 40px;"><span class="LanguageDot-module__languageDot--h8s9C" style="box-sizing: border-box; background-color: rgb(227, 140, 0); border-color: rgba(31, 35, 40, 0.15); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; border-radius: 9999px; display: inline-block; height: 10px; width: 10px;"></span><span id=":r16e:" class="CodeBlock-module__languageName--ZLWCa" style="box-sizing: border-box; flex-grow: 1; font-size: 14px; margin-left: 4px;">SQL</span><button data-component="IconButton" type="button" class="prc-Button-ButtonBase-c50BI prc-Button-IconButton-szpyj" data-loading="false" data-no-visuals="true" data-size="medium" data-variant="invisible" aria-describedby=":r16g:-loading-announcement" aria-labelledby=":r16f:" style="box-sizing: border-box; font-style: inherit; font-variant: inherit; font-weight: 500; font-stretch: inherit; font-size: 14px; line-height: inherit; font-family: inherit; font-optical-sizing: inhe rit; font-size-adjust: inherit; font-kerning: inherit; font-feature-settings: inherit; font-variation-settings: inherit; margin: 0px; overflow: visible; text-transform: none; appearance: none; cursor: pointer; border-radius: 6px; align-items: center; background-color: initial; border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; border-color: rgba(0, 0, 0, 0); color: rgb(89, 99, 110); display: inline-grid; gap: 8px; height: 32px; place-content: center; min-width: unset; padding: unset; text-align: center; text-decoration: none; transition: color 80ms cubic-bezier(0.65, 0, 0.35, 1), fill, background-color, border-color; user-select: none; flex-shrink: 0; width: 32px; box-shadow: none;"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M1 13h3M1 3h14"></path><path fill="currentColor" fill-rule="even odd" d="M1 7.25a.75.75 0 0 0 0 1.5h11.5a1.75 1.75 0 1 1 0 3.5H9.536v-.464a.679.679 0 0 0-1.086-.543l-1.619 1.214a.68.68 0 0 0 0 1.086l1.619 1.214a.679.679 0 0 0 1.086-.543v-.464H12.5a3.25 3.25 0 0 0 0-6.5z" clip-rule="evenodd"></path></svg></button></div><div class="CodeBlock-module__copyContainer--HAOPj" style="box-sizing: border-box; position: sticky; top: 48px;"><div class="CodeBlock-module__copyContent--RfUYZ" style="box-sizing: border-box; right: 8px; align-items: center; bottom: 0px; display: flex; height: 48px; position: absolute;"><button data-component="IconButton" type="button" class="prc-Button-ButtonBase-c50BI CodeBlock-module__copyButton--zcOKE prc-Button-IconButton-szpyj" data-loading="false" data-no-visuals="true" data-size="medium" data-variant="invisible" aria-describedby=":r16j:-loading-announcement" aria-labelledby=":r16h:" style="box-sizing: border-box; font-style: inherit; font-variant: inherit; font-weight: 500; font-stretch: inherit; font-size: 14px; line-heig ht: inherit; font-family: inherit; font-optical-sizing: inherit; font-size-adjust: inherit; font-kerning: inherit; font-feature-settings: inherit; font-variation-settings: inherit; margin: 0px; overflow: visible; text-transform: none; appearance: none; cursor: pointer; border-radius: 6px; align-items: center; background-color: rgb(246, 248, 250); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; border-color: rgba(0, 0, 0, 0); color: rgb(89, 99, 110); display: inline-grid; gap: 8px; height: 32px; place-content: center; min-width: unset; padding: unset; text-align: center; text-decoration: none; transition: color 80ms cubic-bezier(0.65, 0, 0.35, 1), fill, background-color, border-color; user-select: none; flex-shrink: 0; width: 32px; box-shadow: none;"><svg aria-hidden="true" focusable="false" class="octicon octicon-copy" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align: text- bottom;"><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg></button></div></div><div class="CodeBlock-module__codeContainer--dAEis" style="box-sizing: border-box; background-color: rgb(255, 255, 255); border-color: rgba(209, 217, 224, 0.7); border-style: solid; border-width: 0px 1px 1px; border-image: none 100% / 1 / 0 stretch; border-radius: 0px 0px 12px 12px; overflow: hidden;"><pre class="CodeBlock-module__code--KUcqT" tabindex="0" style="box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono" ;, monospace; font-size: 11.9px; margin: 0px !important; overflow-wrap: normal; padding: 16px 24px !important; overflow: auto; line-height: 1.45; color: rgb(31, 35, 40); background: none !important; border-radius: 0px !important;"><code class="" style="box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 11.9px; padding: 0px; margin: 0px; white-space: pre; background: transparent; border-radius: 6px; word-break: normal; border: 0px; display: inline; overflow: visible; line-height: inherit; overflow-wrap: normal;"><span class="hljs-built_in" style="box-sizing: border-box; color: rgb(149, 56, 0);"><span style="box-sizing: border-box;">LAG</span></span><span style="box-sizing: border-box;">(salary, </span><span class="hljs-number" style="box-sizing: border-box; color: rgb(5, 80, 174);"><span style="box-sizing: border-box;">2</span></span><span style="box-sizing: border-box;">, </span> <span class="hljs-number" style="box-sizing: border-box; color: rgb(5, 80, 174);"><span style="box-sizing: border-box;">0</span></span><span style="box-sizing: border-box;">) </span><span class="hljs-keyword" style="box-sizing: border-box; color: rgb(207, 34, 46);"><span style="box-sizing: border-box;">OVER</span></span> <span style="box-sizing: border-box;">(</span><span class="hljs-keyword" style="box-sizing: border-box; color: rgb(207, 34, 46);"><span style="box-sizing: border-box;">PARTITION</span></span> <span class="hljs-keyword" style="box-sizing: border-box; color: rgb(207, 34, 46);"><span style="box-sizing: border-box;">BY</span></span> <span style="box-sizing: border-box;">dept </span><span class="hljs-keyword" style="box-sizing: border-box; color: rgb(207, 34, 46);"><span style="box-sizing: border-box;">ORDER</span></span> <span class="hljs-keyword" style="box-sizing: border-box; color: rgb(207, 34, 46);"><span style="box-sizing: border-box;">BY</span></span> <span style= "box-sizing: border-box;">hire_date) </span></code></pre></div></figure><ul style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: -apple-system, "system-ui", "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><li style="box-sizing: border-box;"><span style="box-sizing: border-box;">The<span> </span></span><span style="box-sizing: border-box;">constants<span> </span></span><span style="box-sizing: border-box;">needed<span> </span>< /span><span style="box-sizing: border-box;">are<span> </span></span><code node="[object Object]" style="box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 11.9px; padding: 0.2em 0.4em; margin: 0px; white-space: break-spaces; background-color: rgba(129, 139, 152, 0.12); border-radius: 6px;"><span style="box-sizing: border-box;">2</span></code><span> </span><span style="box-sizing: border-box;">and<span> </span></span><code node="[object Object]" style="box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 11.9px; padding: 0.2em 0.4em; margin: 0px; white-space: break-spaces; background-color: rgba(129, 139, 152, 0.12); border-radius: 6px;"><span style="box-sizing: border-box;">0</span></code><span style="box-sizing: border-box;">,<span> </span></span><span style="box-sizing: bo rder-box;">so<span> </span></span><code node="[object Object]" style="box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 11.9px; padding: 0.2em 0.4em; margin: 0px; white-space: break-spaces; background-color: rgba(129, 139, 152, 0.12); border-radius: 6px;"><span style="box-sizing: border-box;">constants </span><span style="box-sizing: border-box;">= </span><span style="box-sizing: border-box;">[2, </span><span style="box-sizing: border-box;">0]</span></code><span style="box-sizing: border-box;">.</span></li></ul><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: -apple-system, "system-ui", "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: norm al; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><strong style="box-sizing: border-box; font-weight: 600;"><span style="box-sizing: border-box;">Input<span> </span></span><span style="box-sizing: border-box;">to<span> </span></span><span style="box-sizing: border-box;">the<span> </span></span><span style="box-sizing: border-box;">Window<span> </span></span><span style="box-sizing: border-box;">node:</span></strong></p> employee_id | salary | 2 | 0 -- | -- | -- | -- ... | ... | 2 | 0 <p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: -apple-system, "system-ui", "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="box-sizing: border-box;">So:</span></p><ul style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(31, 35, 40); font-family: -apple-system, "system-ui", "Segoe UI", "Noto Sans", Helvetica, Arial, s ans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><li style="box-sizing: border-box;"><code node="[object Object]" style="box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 11.9px; padding: 0.2em 0.4em; margin: 0px; white-space: break-spaces; background-color: rgba(129, 139, 152, 0.12); border-radius: 6px;"><span style="box-sizing: border-box;">RexInputRef(0)</span></code><span> </span><span style="box-sizing: border-box;">→<span> </ span></span><span style="box-sizing: border-box;">employee_id</span></li><li style="box-sizing: border-box; margin-top: 0.25em;"><code node="[object Object]" style="box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 11.9px; padding: 0.2em 0.4em; margin: 0px; white-space: break-spaces; background-color: rgba(129, 139, 152, 0.12); border-radius: 6px;"><span style="box-sizing: border-box;">RexInputRef(1)</span></code><span> </span><span style="box-sizing: border-box;">→<span> </span></span><span style="box-sizing: border-box;">salary</span></li><li style="box-sizing: border-box; margin-top: 0.25em;"><code node="[object Object]" style="box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 11.9px; padding: 0.2em 0.4em; margin: 0px; white-space: break-spaces; background-color: rgba (129, 139, 152, 0.12); border-radius: 6px;"><span style="box-sizing: border-box;">RexInputRef(2)</span></code><span> </span><span style="box-sizing: border-box;">→<span> </span></span><span style="box-sizing: border-box;">constants[0]<span> </span></span><span style="box-sizing: border-box;">=<span> </span></span><span style="box-sizing: border-box;">2</span></li><li style="box-sizing: border-box; margin-top: 0.25em;"><code node="[object Object]" style="box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 11.9px; padding: 0.2em 0.4em; margin: 0px; white-space: break-spaces; background-color: rgba(129, 139, 152, 0.12); border-radius: 6px;"><span style="box-sizing: border-box;">RexInputRef(3)</span></code><span> </span><span style="box-sizing: border-box;">→<span> </span></span><span style="box-sizing: border-box;">constants[1]<span> </span></span><span style="box-sizing: border-box;">=<span> </span></span><span style="box-sizing: border-box;">0</span></li></ul> -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org