calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jh...@apache.org
Subject [1/3] calcite git commit: [CALCITE-969] Composite EnumerableSort with DESC wrongly sorts NULL values low
Date Tue, 17 Nov 2015 19:30:59 GMT
Repository: calcite
Updated Branches:
  refs/heads/master 10830827e -> c78092454


[CALCITE-969] Composite EnumerableSort with DESC wrongly sorts NULL values low


Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/80bbb5bf
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/80bbb5bf
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/80bbb5bf

Branch: refs/heads/master
Commit: 80bbb5bf2a53612be6bf2e6f086141e84c5e9a61
Parents: 1083082
Author: Julian Hyde <jhyde@apache.org>
Authored: Mon Nov 16 11:05:49 2015 -0800
Committer: Julian Hyde <jhyde@apache.org>
Committed: Mon Nov 16 11:12:19 2015 -0800

----------------------------------------------------------------------
 .../adapter/enumerable/PhysTypeImpl.java        |  6 ++--
 core/src/test/resources/sql/sort.oq             | 32 ++++++++++++++++++++
 2 files changed, 35 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/80bbb5bf/core/src/main/java/org/apache/calcite/adapter/enumerable/PhysTypeImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/PhysTypeImpl.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/PhysTypeImpl.java
index 1cc6628..af42c16 100644
--- a/core/src/main/java/org/apache/calcite/adapter/enumerable/PhysTypeImpl.java
+++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/PhysTypeImpl.java
@@ -308,9 +308,9 @@ public class PhysTypeImpl implements PhysType {
                   Expressions.call(
                       Utilities.class,
                       fieldNullable(index)
-                          ? (nullsFirst
-                          ? "compareNullsFirst"
-                          : "compareNullsLast")
+                          ? (nullsFirst ^ descending
+                              ? "compareNullsFirst"
+                              : "compareNullsLast")
                           : "compare",
                       arg0,
                       arg1))));

http://git-wip-us.apache.org/repos/asf/calcite/blob/80bbb5bf/core/src/test/resources/sql/sort.oq
----------------------------------------------------------------------
diff --git a/core/src/test/resources/sql/sort.oq b/core/src/test/resources/sql/sort.oq
index 5a25b6b..664a3c4 100644
--- a/core/src/test/resources/sql/sort.oq
+++ b/core/src/test/resources/sql/sort.oq
@@ -68,6 +68,38 @@ EnumerableCalc(expr#0..1=[{inputs}], expr#2=[2], expr#3=[>=($t0, $t2)],
expr#4=[
   EnumerableTableScan(table=[[foodmart2, days]])
 !plan
 
+# [CALCITE-970] Default collation of NULL values
+# Nulls high, i.e. last if ASC
+select "store_id", "grocery_sqft" from "store"
+where "store_id" < 3
+order by 2;
++----------+--------------+
+| store_id | grocery_sqft |
++----------+--------------+
+|        1 |        17475 |
+|        2 |        22271 |
+|        0 |              |
++----------+--------------+
+(3 rows)
+
+!ok
+
+# [CALCITE-969] Composite EnumerableSort with DESC wrongly sorts NULL values low
+# Nulls high, i.e. last if ASC, composite sort
+select "store_id", "grocery_sqft" from "store"
+where "store_id" < 3
+order by "florist", 2;
++----------+--------------+
+| store_id | grocery_sqft |
++----------+--------------+
+|        1 |        17475 |
+|        2 |        22271 |
+|        0 |              |
++----------+--------------+
+(3 rows)
+
+!ok
+
 !use post
 
 # [CALCITE-603] WITH ... ORDER BY cannot find table


Mime
View raw message