You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Letian Jiang (Jira)" <ji...@apache.org> on 2026/10/17 09:41:00 UTC

[jira] [Created] (CALCITE-7864) RANGE window frames should handle NULL ORDER BY keys

Letian Jiang created CALCITE-7864:
-------------------------------------

             Summary: RANGE window frames should handle NULL ORDER BY keys
                 Key: CALCITE-7864
                 URL: https://issues.apache.org/jira/browse/CALCITE-7864
             Project: Calcite
          Issue Type: Bug
          Components: core
            Reporter: Letian Jiang


EnumerableWindow throws a NullPointerException when evaluating
a RANGE frame with an offset bound and a NULL ORDER BY key,
because the generated boundary arithmetic unboxes the NULL key.

Reproducer:
SELECT k,
       SUM(v) OVER (
         ORDER BY k NULLS LAST
         RANGE BETWEEN 1 PRECEDING AND CURRENT ROW
       ) AS s
FROM (VALUES (1, 10), (2, 20),
             (CAST(NULL AS INTEGER), 100), (NULL, 200)) AS t(k, v)

Expected results, ignoring row order:
(1, 10), (2, 30), (NULL, 300), (NULL, 300).

Actual result: NullPointerException.

Offset RANGE boundaries for a NULL key should use the corresponding
edge of its NULL peer group. This should work with both NULLS FIRST
and NULLS LAST, for both lower and upper bounds.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)