Skip to content

default null ordering is opposite of PostgreSQL #3204

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

Closed
xiangjinwu opened this issue Jun 14, 2022 · 0 comments · Fixed by #4263
Closed

default null ordering is opposite of PostgreSQL #3204

xiangjinwu opened this issue Jun 14, 2022 · 0 comments · Fixed by #4263
Labels
A-common Area: `src/common` things, array, data type, row, etc. type/bug Type: Bug. Only for issues.

Comments

@xiangjinwu
Copy link
Contributor

Describe the bug
We do not support specifying nulls {first | last} yet. When nothing is specified, the default behavior of PostgreSQL is to treat nulls as larger than non-nulls (i.e. nulls last for asc and nulls first for desc).

But in our current implementation, memcomparable encodes nulls as smaller than non-nulls. And parts not using memcomparable are implemented to keep consistent with it rather than PostgreSQL.

To Reproduce

create table t (v1 int);
insert into t values (2), (null), (3), (1);

select * from t order by v1;
select * from t order by v1 desc;
select * from t order by v1 limit 2;
select * from t order by v1 desc limit 2;
create materialized view mv_a as select * from t order by v1;
create materialized view mv_d as select * from t order by v1 desc;
create materialized view mv_a2 as select * from t order by v1 limit 2;
create materialized view mv_d2 as select * from t order by v1 desc limit 2;
select * from mv_a;
select * from mv_d;
select * from mv_a2;
select * from mv_d2;

Expected behavior
Same behavior as PostgreSQL.

Additional context
Do not see an immediate need to fix it (before fully supporting nulls {first | last}). Just documenting the current behavior. And we should fix the default behavior when we implement nulls {first | last}.

@xiangjinwu xiangjinwu added type/bug Type: Bug. Only for issues. A-common Area: `src/common` things, array, data type, row, etc. labels Jun 14, 2022
@mergify mergify bot closed this as completed in #4263 Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-common Area: `src/common` things, array, data type, row, etc. type/bug Type: Bug. Only for issues.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant