Mihai Budiu created CALCITE-7435:
------------------------------------

             Summary: WINDOW functions do not allolw ORDER BY fields of type 
INTERVAL
                 Key: CALCITE-7435
                 URL: https://issues.apache.org/jira/browse/CALCITE-7435
             Project: Calcite
          Issue Type: Bug
          Components: core
            Reporter: Mihai Budiu


{code:java}
CREATE TABLE data (
   t0 TIMESTAMP NOT NULL,
   location INT NOT NULL
);
                
CREATE VIEW IT AS SELECT (t0 - TIMESTAMP '2020-01-01 00:00:00') SECOND AS t, 
location FROM data;
                
CREATE VIEW V AS
SELECT
   *,
   COUNT(*) OVER(
      PARTITION BY location
      ORDER BY t
      RANGE BETWEEN INTERVAL '2' DAYS PRECEDING AND INTERVAL '1' DAYS 
PRECEDING) AS c
FROM IT; {code}
Calcite's syntax for arithmetic on timestamps is not accepted by other 
databases, so I could not validate this query, but I see no reason it should be 
rejected.

Validation fails in SqlTypeFamily.allowableDifferenceTypes, which only accepts 
NUMERIC, DATE, TIME, and TIMESTAMP types. But since INTERVAL types support the 
minus operation, I think they should be allowed too.

 



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

Reply via email to