LucidDB / luciddb

DEFUNCT: See README
https://github.com/LucidDB/luciddb
Apache License 2.0
53 stars 24 forks source link

[FRG-181] Type of window function avg() after SqlToRel conversion does not agree with the original Sql type #691

Open dynamobi-build opened 12 years ago

dynamobi-build commented 12 years ago

[reporter="rchen", created="Tue, 8 Aug 2006 12:49:49 -0500 (GMT-05:00)"] set schema 'sales';

explain plan without implementation for
select avg(empno) over w1
from emps window w1 as (partition by deptno order by age rows 2 preceding);

Error: java.lang.AssertionError: Internal error: Conversion to relational algebra failed to preserve datatypes:
validated type:
RecordType(INTEGER EXPR$0) NOT NULL
converted type:
RecordType(BIGINT EXPR$0) NOT NULL
rel:
ProjectRel(EXPR$0=[CASE(=(COUNT($0) OVER (PARTITION BY $2 ORDER BY $6 ROWS 2 PRECEDING), 0), CAST(null):INTEGER, /(SUM($0) OVER (PARTITION BY $2 ORDER BY $6 ROWS 2 PRECEDING), COUNT($0) OVER (PARTITION BY $2 ORDER BY $6 ROWS 2 PRECEDING)))])
  TableAccessRel(table=[[LOCALDB, SALES, EMPS]]) (state=,code=0)

dynamobi-build commented 12 years ago

[author="rchen", created="Tue, 8 Aug 2006 13:24:46 -0500 (GMT-05:00)"] Correction: currently only the query triggers the error, not EXPLAIn PLAN though it should.

select avg(empno) over w1
from emps window w1 as (partition by deptno order by age rows 2 preceding);

This query comes from farrago/src/org/eigenbase/test/SqlToRelConverterTest.java::testOverAvg().

dynamobi-build commented 12 years ago

[author="jhyde", created="Wed, 9 Aug 2006 23:27:18 -0500 (GMT-05:00)"] Assign to Jack. It's similar to another problem he's already investigating.