Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opt,sql: disallow column references in ROWS/RANGE #40832

Merged
merged 1 commit into from
Sep 19, 2019

Commits on Sep 18, 2019

  1. opt,sql: disallow column references in ROWS/RANGE

    Fixes cockroachdb#38286.
    
    This is a departure from the behaviour of the heuristic planner but is
    actually the same behaviour as Postgres:
    
    ```
    d=# create table x (a int primary key);
    CREATE TABLE
    d=# select rank() over (order by a range between a preceding and unbounded following) from x;
    ERROR:  argument of RANGE must not contain variables
    LINE 1: select rank() over (order by a range between a preceding and...
    ```
    
    Our behaviour now:
    ```
    root@127.0.0.1:60679/movr> CREATE TABLE x (a INT8 PRIMARY KEY)
    CREATE TABLE
    
    root@127.0.0.1:60679/movr> SELECT
        rank() OVER (ORDER BY a RANGE BETWEEN a PRECEDING AND UNBOUNDED FOLLOWING)
    FROM
        x
    pq: ROWS or RANGE cannot contain variables
    ```
    
    Release justification: Category 2: Fixes a bug and brings behaviour more
    in-line with Postgres.
    
    Release note (sql change): column references are no longer allowed in
    ROWS/RANGE clauses in window functions.
    Justin Jaffray committed Sep 18, 2019
    Configuration menu
    Copy the full SHA
    7a8fdfb View commit details
    Browse the repository at this point in the history