questdb
questdb copied to clipboard
fix(sql): fix bug of empty string and null string selection(#1916)
This commit is aimed to solve the issue mentioned in #issue1916 https://github.com/questdb/questdb/issues/1916. The problem occurs when a symbol column is indexed, during selection null strings and empty strings are not correctly distinguished.
The error found is the miss of detection for empty strings in Functionparser.createBindVariable. In this commit, I edited only this method and updated four relevant Junit tests.
Hi @Twilight-Shuxin, I was also trying to fix this bug, IMHO the point is index, not symbol. Please correct me if I'm wrong, but your changes seem not to fix this bug, tested as below:
create table foo (
x symbol index
);
insert into foo
values ('bar'), ('baz'),
(' '),
(''), (''),
(null);
select * from foo where x != ''; -- returns 3 rows, null is missing
create table bar (
x symbol
);
insert into bar
values ('bar'), ('baz'),
(' '),
(''), (''),
(null);
select * from bar where x != ''; -- returns 4 rows
@HeZean Hi, thanks for this remind!I think my edition is correct, but the found of this bug shows that there are still mistakes around. The problem in this case might be occuring during the parsing process of '!=' for indexed columns, since for all '=' signs I tested there seems to be no error occuring.
@HeZean It really does seem a little confusing to me. Inside SqlCodeGenerator.java generateTableQuery, there is a metadata to record whether data is indexed or not. In the '=' case, I found out that if flag is modified to not indexed(while the data is actually indexed), it generates a correct answer(as consistant with non-indexed case). However when it turns to '!=', even when flag is modified to not-indexed, the answer is still different from having a non-indexed column. This might be a deeper hidden error.
I wouldn't try to fix #1916 without also fixing #1914 at the same time.
I wouldn't try to fix #1916 without also fixing #1914 at the same time.
Yes, I'm sorry for my mistake for not noticing the remaining bug. But I'm too busy for this few days and I think I'll try my best to continue to solve it afterwards if by then the issue is still not solved yet.