m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin <marcin.j.chrzanowski@gmail.com>2019-11-24 12:29:21 +0100
committerGitHub <noreply@github.com>2019-11-24 12:29:21 +0100
commit38e6415804f7a956de04fe1b61660cbff6dcecf8 (patch)
treeb8407782c5d47b00deb0c13334e4ffcf27a9e6d0 /src
parent9ea3ac76a93e4256dd8926574b2225726c6744cf (diff)
Test ORDER BY functionality (#30)
Diffstat (limited to 'src')
-rw-r--r--src/test/java/pl/edu/mimuw/cloudatlas/interpreter/InterpreterTests.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/interpreter/InterpreterTests.java b/src/test/java/pl/edu/mimuw/cloudatlas/interpreter/InterpreterTests.java
index 1c7be00..fdc6fd2 100644
--- a/src/test/java/pl/edu/mimuw/cloudatlas/interpreter/InterpreterTests.java
+++ b/src/test/java/pl/edu/mimuw/cloudatlas/interpreter/InterpreterTests.java
@@ -607,6 +607,62 @@ public class InterpreterTests {
);
}
+ @Test
+ public void testNullFromEmptyColumn() throws Exception {
+ assertInterpreterRun(
+ "SELECT max(num_cores) AS num_cores WHERE cpu_usage = 0.1",
+ new String[] {
+ "/uw: num_cores: NULL",
+ "/pjwstk: num_cores: 7",
+ "/: num_cores: NULL"
+ }
+ );
+ }
+
+ @Test
+ public void testOrderDescending() throws Exception {
+ assertInterpreterRun(
+ "SELECT first(1, unfold(php_modules)) AS php_modules ORDER BY cpu_usage DESC NULLS LAST",
+ new String[] {
+ "/pjwstk: php_modules: [odbc]",
+ "/: php_modules: [odbc]",
+ }
+ );
+ }
+
+ @Test
+ public void testOrderAscending() throws Exception {
+ assertInterpreterRun(
+ "SELECT first(1, unfold(php_modules)) AS php_modules ORDER BY cpu_usage ASC NULLS LAST",
+ new String[] {
+ "/pjwstk: php_modules: [rewrite]",
+ "/: php_modules: [rewrite]"
+ }
+ );
+ }
+
+ @Test
+ public void testOrderNullsFirst() throws Exception {
+ assertInterpreterRun(
+ "SELECT first(1, unfold(some_names)) AS some_names ORDER BY has_ups NULLS FIRST",
+ new String[] {
+ "/uw: some_names: [tola]",
+ "/: some_names: [tola]"
+ }
+ );
+ }
+
+ @Test
+ public void testOrderNullsLast() throws Exception {
+ assertInterpreterRun(
+ "SELECT last(1, unfold(some_names)) AS some_names ORDER BY has_ups NULLS LAST",
+ new String[] {
+ "/uw: some_names: [tosia]",
+ "/: some_names: [tosia]"
+ }
+ );
+ }
+
private void assertInterpreterRun(String query, String[] expectedOutput) throws Exception {
ByteArrayInputStream in = new ByteArrayInputStream(query.getBytes());