You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by tl...@apache.org on 2021/05/28 12:36:29 UTC

[ignite] branch sql-calcite updated: IGNITE-14779 Unblock NULLS FIRST|LAST functionality checks (#9128)

This is an automated email from the ASF dual-hosted git repository.

tledkov pushed a commit to branch sql-calcite
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/sql-calcite by this push:
     new 20aa711  IGNITE-14779 Unblock NULLS FIRST|LAST functionality checks (#9128)
20aa711 is described below

commit 20aa711e1fa7f2f03aa258430c38924009f09195
Author: Evgeniy Stanilovskiy <st...@gmail.com>
AuthorDate: Fri May 28 15:36:07 2021 +0300

    IGNITE-14779 Unblock NULLS FIRST|LAST functionality checks (#9128)
---
 .../query/calcite/CalciteQueryProcessorTest.java   | 43 +++++++++++++++++++
 .../src/test/sql/order/test_nulls_first.ignore     | 20 +++++++++
 .../src/test/sql/order/test_nulls_first.test       | 48 +---------------------
 3 files changed, 64 insertions(+), 47 deletions(-)

diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessorTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessorTest.java
index 0000bfb..d5950a7 100644
--- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessorTest.java
+++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessorTest.java
@@ -520,6 +520,49 @@ public class CalciteQueryProcessorTest extends GridCommonAbstractTest {
 
     /** */
     @Test
+    public void testSortNullsDirection() throws Exception {
+        IgniteCache<Integer, Employer> orders = client.getOrCreateCache(new CacheConfiguration<Integer, Employer>()
+            .setName("orders")
+            .setSqlSchema("PUBLIC")
+            .setQueryEntities(F.asList(new QueryEntity(Integer.class, Employer.class).setTableName("orders")))
+            .setBackups(1)
+        );
+
+        orders.put(1, new Employer("Igor", 10d));
+        orders.put(2, new Employer("Igor", 11d));
+        orders.put(3, new Employer("Igor", 12d));
+        orders.put(4, new Employer("Igor1", 13d));
+        orders.put(5, new Employer("Igor1", 13d));
+        orders.put(6, new Employer("Igor1", null));
+        orders.put(7, new Employer("Roman", null));
+
+        List<List<?>> rows = sql(
+            "SELECT salary FROM Orders ORDER BY salary", true);
+
+        List<List<?>> rows0 = sql(
+            "SELECT salary FROM Orders ORDER BY salary NULLS LAST", true);
+
+        assertEquals(7, rows.size());
+        assertEquals(rows, rows0);
+
+        rows = sql(
+            "SELECT _KEY FROM Orders ORDER BY salary", true);
+
+        rows0 = sql(
+            "SELECT _KEY FROM Orders ORDER BY salary NULLS LAST", true);
+
+        assertEquals(7, rows.size());
+        assertEquals(rows, rows0);
+
+        rows = sql(
+            "SELECT salary FROM Orders ORDER BY salary NULLS FIRST LIMIT 1", true);
+
+        assertEquals(1, rows.size());
+        assertEquals(null, rows.get(0).get(0));
+    }
+
+    /** */
+    @Test
     public void testEqConditionWithDistinctSubquery() throws Exception {
         populateTables();
 
diff --git a/modules/calcite/src/test/sql/order/test_nulls_first.ignore b/modules/calcite/src/test/sql/order/test_nulls_first.ignore
new file mode 100644
index 0000000..e7b0611
--- /dev/null
+++ b/modules/calcite/src/test/sql/order/test_nulls_first.ignore
@@ -0,0 +1,20 @@
+# name: test/sql/order/test_nulls_first.test
+# description: Test NULLS FIRST/NULLS LAST
+# group: [order]
+# Ignored: https://issues.apache.org/jira/browse/IGNITE-14777
+
+# now in window functions
+
+query III
+SELECT i, j, row_number() OVER (PARTITION BY i ORDER BY j NULLS FIRST) FROM test ORDER BY i NULLS FIRST, j NULLS FIRST;
+----
+NULL	1	1
+1	NULL	1
+1	1	2
+
+query III
+SELECT i, j, row_number() OVER (PARTITION BY i ORDER BY j NULLS LAST) FROM test ORDER BY i NULLS FIRST, j NULLS FIRST;
+----
+NULL	1	1
+1	NULL	2
+1	1	1
diff --git a/modules/calcite/src/test/sql/order/test_nulls_first.test b/modules/calcite/src/test/sql/order/test_nulls_first.test
index 02de6ae..a97084a 100644
--- a/modules/calcite/src/test/sql/order/test_nulls_first.test
+++ b/modules/calcite/src/test/sql/order/test_nulls_first.test
@@ -15,8 +15,8 @@ INSERT INTO integers VALUES (1), (NULL)
 query I
 SELECT * FROM integers ORDER BY i
 ----
-NULL
 1
+NULL
 
 query I
 SELECT * FROM integers ORDER BY i NULLS FIRST
@@ -64,21 +64,6 @@ SELECT * FROM test ORDER BY i NULLS LAST, j NULLS FIRST
 1	1
 NULL	1
 
-# now in window functions
-query III
-SELECT i, j, row_number() OVER (PARTITION BY i ORDER BY j NULLS FIRST) FROM test ORDER BY i NULLS FIRST, j NULLS FIRST;
-----
-NULL	1	1
-1	NULL	1
-1	1	2
-
-query III
-SELECT i, j, row_number() OVER (PARTITION BY i ORDER BY j NULLS LAST) FROM test ORDER BY i NULLS FIRST, j NULLS FIRST;
-----
-NULL	1	1
-1	NULL	2
-1	1	1
-
 # TOP N
 query II
 SELECT * FROM test ORDER BY i NULLS FIRST, j NULLS LAST LIMIT 2
@@ -91,34 +76,3 @@ SELECT * FROM test ORDER BY i NULLS LAST, j NULLS LAST LIMIT 2
 ----
 1	1
 1	NULL
-
-# Test NULLS FIRST/NULLS LAST PRAGMA
-# default is NULLS FIRST
-query I
-SELECT * FROM integers ORDER BY i
-----
-NULL
-1
-
-# changed default now
-statement ok
-PRAGMA default_null_order='NULLS LAST'
-
-query I
-SELECT * FROM integers ORDER BY i
-----
-1
-NULL
-
-statement ok
-PRAGMA default_null_order='NULLS FIRST'
-
-statement error
-PRAGMA default_null_order())
-
-statement error
-PRAGMA default_null_order=UNKNOWN)
-
-statement error
-PRAGMA default_null_order=3)
-