LucidDB / luciddb

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

[FRG-208] null values not getting filtered out #664

Closed dynamobi-build closed 12 years ago

dynamobi-build commented 12 years ago

[reporter="elin", created="Tue, 19 Sep 2006 15:02:22 -0500 (GMT-05:00)"] Null values aren't getting filtered out of statements when indices aren't created prior to insertion for statements such as the one below:

select * from blahtable where somecol < 5;

-- repro:
create schema ss;
set schema 'ss';
create table tt(v varchar primary key, i int);
insert into tt values
('a', 1), ('b', 2), ('c', null), ('d', 4), ('e', null), ('f', 6);

select * from tt;
-- produces:
+----+----+
| V | I |
+----+----+
| a | 1 |
| b | 2 |
| c | |
| d | 4 |
| e | |
| f | 6 |
+----+----+

select * from tt where i < 5;
-- produces:
+----+----+
| V | I |
+----+----+
| a | 1 |
| b | 2 |
| c | |
| d | 4 |
| e | |
+----+----+

-- if index is created at this point, we still have the same problem
create index i_index on tt(i);

-- but if it's created prior to insertions like so:
create table twi (v varchar primary key, i int);
create index twi_i on twi(i);
insert into twi values
('a', 1), ('b', 2), ('c', null), ('d', 4), ('e', null), ('f', 6);

--then we get the correct results
select * from twi where i < 5;

+----+----+
| V | I |
+----+----+
| a | 1 |
| b | 2 |
| d | 4 |
+----+----+


(self, remember to fix ref file for company-noidx-test.null when issue is fixed)

dynamobi-build commented 12 years ago

[author="jvs", created="Tue, 19 Sep 2006 15:10:20 -0500 (GMT-05:00)"] Oops...TupleDescriptor::compareKeys treats nulls as normal values sorted below everything else (because those are the semantics needed for index ordering). Guess we need a different version, except for the IS NULL case :(

dynamobi-build commented 12 years ago

[author="jvs", created="Tue, 19 Sep 2006 15:13:21 -0500 (GMT-05:00)"] It is a sad fact that Farrago didn't have any existing tests to catch this.

dynamobi-build commented 12 years ago

[author="zfong", created="Tue, 19 Sep 2006 22:02:39 -0500 (GMT-05:00)"] Fix checked into lu/dev in Eigenchange 7712.