Skip to content

Window functions panic due to interface conversion error #3038

Description

@angelamayxie

New window function tests were added in dolthub/go-mysql-server#3666 but fail in Doltgres, panicking due to an interface conversion error.

ERROR: DoltgresHandler caught panic: interface conversion: interface {} is float64, not int32

These queries work in Postgres, but some of them do return slightly different results than MySQL, likely due to floating point or rounding errors.

postgres=# CREATE TABLE t2 (id BIGINT PRIMARY KEY, grp VARCHAR(10), val INT);
CREATE TABLE
postgres=# INSERT INTO t2 VALUES (1,'a',10), (2,'a',20), (3,'b',30), (4,'b',5), (5,'c',15), (6,'c',25);
INSERT 0 6
postgres=# SELECT id, STDDEV_POP(val) OVER (ORDER BY grp) FROM t2 ORDER BY id;
 id |     stddev_pop     
----+--------------------
  1 | 5.0000000000000000
  2 | 5.0000000000000000
  3 | 9.6014321848357602
  4 | 9.6014321848357602
  5 | 8.5391256382996653
  6 | 8.5391256382996653
(6 rows)

postgres=# SELECT id, STDDEV_SAMP(val) OVER (ORDER BY grp) FROM t2 ORDER BY id;
 id |     stddev_samp     
----+---------------------
  1 |  7.0710678118654752
  2 |  7.0710678118654752
  3 | 11.0867789130417256
  4 | 11.0867789130417256
  5 |  9.3541434669348535
  6 |  9.3541434669348535
(6 rows)

postgres=# SELECT id, VAR_POP(val) OVER (ORDER BY grp) FROM t2 ORDER BY id;
 id |       var_pop       
----+---------------------
  1 | 25.0000000000000000
  2 | 25.0000000000000000
  3 | 92.1875000000000000
  4 | 92.1875000000000000
  5 | 72.9166666666666667
  6 | 72.9166666666666667
(6 rows)

postgres=# SELECT id, VAR_SAMP(val) OVER (ORDER BY grp) FROM t2 ORDER BY id;
 id |       var_samp       
----+----------------------
  1 |  50.0000000000000000
  2 |  50.0000000000000000
  3 | 122.9166666666666667
  4 | 122.9166666666666667
  5 |  87.5000000000000000
  6 |  87.5000000000000000
(6 rows)

Failing test cases are skipped in Doltgres for now but please unskip them once they've been fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions