提交 dfb7bba0 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Detect ordered result sets properly

上级 3e2bf8da
...@@ -27,8 +27,13 @@ import java.util.Map; ...@@ -27,8 +27,13 @@ import java.util.Map;
import java.util.Random; import java.util.Random;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.command.CommandContainer;
import org.h2.command.CommandInterface;
import org.h2.command.Prepared;
import org.h2.command.dml.Query;
import org.h2.engine.SysProperties; import org.h2.engine.SysProperties;
import org.h2.jdbc.JdbcConnection; import org.h2.jdbc.JdbcConnection;
import org.h2.jdbc.JdbcPreparedStatement;
import org.h2.test.TestAll; import org.h2.test.TestAll;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.test.TestDb; import org.h2.test.TestDb;
...@@ -42,6 +47,12 @@ public class TestScript extends TestDb { ...@@ -42,6 +47,12 @@ public class TestScript extends TestDb {
private static final String BASE_DIR = "org/h2/test/scripts/"; private static final String BASE_DIR = "org/h2/test/scripts/";
private static final Field COMMAND;
private static final Field PREPARED;
private static boolean CHECK_ORDERING;
/** If set to true, the test will exit at the first failure. */ /** If set to true, the test will exit at the first failure. */
private boolean failFast; private boolean failFast;
/** If set to a value the test will add all executed statements to this list */ /** If set to a value the test will add all executed statements to this list */
...@@ -59,12 +70,24 @@ public class TestScript extends TestDb { ...@@ -59,12 +70,24 @@ public class TestScript extends TestDb {
private Random random = new Random(1); private Random random = new Random(1);
static {
try {
COMMAND = JdbcPreparedStatement.class.getDeclaredField("command");
COMMAND.setAccessible(true);
PREPARED = CommandContainer.class.getDeclaredField("prepared");
PREPARED.setAccessible(true);
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
}
/** /**
* Run just this test. * Run just this test.
* *
* @param a ignored * @param a ignored
*/ */
public static void main(String... a) throws Exception { public static void main(String... a) throws Exception {
CHECK_ORDERING = true;
TestBase.createCaller().init().test(); TestBase.createCaller().init().test();
} }
...@@ -421,10 +444,20 @@ public class TestScript extends TestDb { ...@@ -421,10 +444,20 @@ public class TestScript extends TestDb {
private int processStatement(String sql) throws Exception { private int processStatement(String sql) throws Exception {
try { try {
if (stat.execute(sql)) { boolean res;
writeResultSet(sql, stat.getResultSet()); Statement s;
if (/* TestScript */ CHECK_ORDERING || /* TestAll */ config.memory && !config.lazy && !config.networked) {
PreparedStatement prep = conn.prepareStatement(sql);
res = prep.execute();
s = prep;
} else {
res = stat.execute(sql);
s = stat;
}
if (res) {
writeResultSet(sql, s.getResultSet());
} else { } else {
int count = stat.getUpdateCount(); int count = s.getUpdateCount();
writeResult(sql, count < 1 ? "ok" : "update count: " + count, null); writeResult(sql, count < 1 ? "ok" : "update count: " + count, null);
} }
} catch (SQLException e) { } catch (SQLException e) {
...@@ -474,6 +507,17 @@ public class TestScript extends TestDb { ...@@ -474,6 +507,17 @@ public class TestScript extends TestDb {
} }
head[i] = label; head[i] = label;
} }
Boolean gotOrdered = null;
Statement st = rs.getStatement();
if (st instanceof JdbcPreparedStatement) {
CommandInterface ci = (CommandInterface) COMMAND.get(st);
if (ci instanceof CommandContainer) {
Prepared p = (Prepared) PREPARED.get(ci);
if (p instanceof Query) {
gotOrdered = ((Query) p).hasOrder();
}
}
}
rs.close(); rs.close();
String line = readLine(); String line = readLine();
putBack(line); putBack(line);
...@@ -495,7 +539,7 @@ public class TestScript extends TestDb { ...@@ -495,7 +539,7 @@ public class TestScript extends TestDb {
return; return;
} }
} }
boolean ordered; Boolean ordered;
for (;;) { for (;;) {
line = readNextLine(); line = readNextLine();
if (line == null) { if (line == null) {
...@@ -509,6 +553,20 @@ public class TestScript extends TestDb { ...@@ -509,6 +553,20 @@ public class TestScript extends TestDb {
} else if (line.startsWith("> rows (ordered): ")) { } else if (line.startsWith("> rows (ordered): ")) {
ordered = true; ordered = true;
break; break;
} else if (line.startsWith("> rows (partially ordered): ")) {
ordered = null;
break;
}
}
if (gotOrdered != null && ordered != null) {
if (ordered) {
if (!gotOrdered) {
addWriteResultError("<ordered result set>", "<result set>");
}
} else {
if (gotOrdered) {
addWriteResultError("<result set>", "<ordered result set>");
}
} }
} }
writeResult(sql, format(head, max), null); writeResult(sql, format(head, max), null);
...@@ -517,14 +575,16 @@ public class TestScript extends TestDb { ...@@ -517,14 +575,16 @@ public class TestScript extends TestDb {
for (int i = 0; i < result.size(); i++) { for (int i = 0; i < result.size(); i++) {
array[i] = format(result.get(i), max); array[i] = format(result.get(i), max);
} }
if (!ordered) { if (!Boolean.TRUE.equals(ordered)) {
sort(array); sort(array);
} }
int i = 0; int i = 0;
for (; i < array.length; i++) { for (; i < array.length; i++) {
writeResult(sql, array[i], null); writeResult(sql, array[i], null);
} }
writeResult(sql, (ordered ? "rows (ordered): " : "rows: ") + i, null); writeResult(sql,
(ordered != null ? ordered ? "rows (ordered): " : "rows: " : "rows (partially ordered): ") + i,
null);
} }
private static String format(String[] row, int[] max) { private static String format(String[] row, int[] max) {
......
...@@ -25,7 +25,7 @@ SELECT * FROM TEST ORDER BY A, B; ...@@ -25,7 +25,7 @@ SELECT * FROM TEST ORDER BY A, B;
> 2 2 1 > 2 2 1
> 2 2 2 > 2 2 2
> 2 2 3 > 2 2 3
> rows (ordered): 12 > rows (partially ordered): 12
SELECT * FROM TEST ORDER BY A, B, C FETCH FIRST 4 ROWS ONLY; SELECT * FROM TEST ORDER BY A, B, C FETCH FIRST 4 ROWS ONLY;
> A B C > A B C
...@@ -43,7 +43,7 @@ SELECT * FROM TEST ORDER BY A, B, C FETCH FIRST 4 ROWS WITH TIES; ...@@ -43,7 +43,7 @@ SELECT * FROM TEST ORDER BY A, B, C FETCH FIRST 4 ROWS WITH TIES;
> 1 1 2 > 1 1 2
> 1 1 3 > 1 1 3
> 1 2 1 > 1 2 1
> rows: 4 > rows (ordered): 4
SELECT * FROM TEST ORDER BY A, B FETCH FIRST 4 ROWS WITH TIES; SELECT * FROM TEST ORDER BY A, B FETCH FIRST 4 ROWS WITH TIES;
> A B C > A B C
...@@ -54,7 +54,7 @@ SELECT * FROM TEST ORDER BY A, B FETCH FIRST 4 ROWS WITH TIES; ...@@ -54,7 +54,7 @@ SELECT * FROM TEST ORDER BY A, B FETCH FIRST 4 ROWS WITH TIES;
> 1 2 1 > 1 2 1
> 1 2 2 > 1 2 2
> 1 2 3 > 1 2 3
> rows: 6 > rows (partially ordered): 6
SELECT * FROM TEST ORDER BY A FETCH FIRST ROW WITH TIES; SELECT * FROM TEST ORDER BY A FETCH FIRST ROW WITH TIES;
> A B C > A B C
...@@ -65,7 +65,7 @@ SELECT * FROM TEST ORDER BY A FETCH FIRST ROW WITH TIES; ...@@ -65,7 +65,7 @@ SELECT * FROM TEST ORDER BY A FETCH FIRST ROW WITH TIES;
> 1 2 1 > 1 2 1
> 1 2 2 > 1 2 2
> 1 2 3 > 1 2 3
> rows: 6 > rows (partially ordered): 6
SELECT TOP (1) WITH TIES * FROM TEST ORDER BY A; SELECT TOP (1) WITH TIES * FROM TEST ORDER BY A;
> A B C > A B C
...@@ -76,7 +76,7 @@ SELECT TOP (1) WITH TIES * FROM TEST ORDER BY A; ...@@ -76,7 +76,7 @@ SELECT TOP (1) WITH TIES * FROM TEST ORDER BY A;
> 1 2 1 > 1 2 1
> 1 2 2 > 1 2 2
> 1 2 3 > 1 2 3
> rows: 6 > rows (partially ordered): 6
SELECT TOP 1 PERCENT WITH TIES * FROM TEST ORDER BY A; SELECT TOP 1 PERCENT WITH TIES * FROM TEST ORDER BY A;
> A B C > A B C
...@@ -87,7 +87,7 @@ SELECT TOP 1 PERCENT WITH TIES * FROM TEST ORDER BY A; ...@@ -87,7 +87,7 @@ SELECT TOP 1 PERCENT WITH TIES * FROM TEST ORDER BY A;
> 1 2 1 > 1 2 1
> 1 2 2 > 1 2 2
> 1 2 3 > 1 2 3
> rows: 6 > rows (partially ordered): 6
SELECT TOP 51 PERCENT WITH TIES * FROM TEST ORDER BY A, B; SELECT TOP 51 PERCENT WITH TIES * FROM TEST ORDER BY A, B;
> A B C > A B C
...@@ -101,7 +101,7 @@ SELECT TOP 51 PERCENT WITH TIES * FROM TEST ORDER BY A, B; ...@@ -101,7 +101,7 @@ SELECT TOP 51 PERCENT WITH TIES * FROM TEST ORDER BY A, B;
> 2 1 1 > 2 1 1
> 2 1 2 > 2 1 2
> 2 1 3 > 2 1 3
> rows: 9 > rows (partially ordered): 9
SELECT * FROM TEST ORDER BY A, B OFFSET 3 ROWS FETCH NEXT 1 ROW WITH TIES; SELECT * FROM TEST ORDER BY A, B OFFSET 3 ROWS FETCH NEXT 1 ROW WITH TIES;
> A B C > A B C
...@@ -109,7 +109,7 @@ SELECT * FROM TEST ORDER BY A, B OFFSET 3 ROWS FETCH NEXT 1 ROW WITH TIES; ...@@ -109,7 +109,7 @@ SELECT * FROM TEST ORDER BY A, B OFFSET 3 ROWS FETCH NEXT 1 ROW WITH TIES;
> 1 2 1 > 1 2 1
> 1 2 2 > 1 2 2
> 1 2 3 > 1 2 3
> rows: 3 > rows (partially ordered): 3
SELECT * FROM TEST FETCH NEXT ROWS ONLY; SELECT * FROM TEST FETCH NEXT ROWS ONLY;
> A B C > A B C
...@@ -163,7 +163,7 @@ SELECT * FROM TEST ORDER BY A FETCH FIRST 1 ROW WITH TIES; ...@@ -163,7 +163,7 @@ SELECT * FROM TEST ORDER BY A FETCH FIRST 1 ROW WITH TIES;
> 1 2 1 > 1 2 1
> 1 2 2 > 1 2 2
> 1 2 3 > 1 2 3
> rows: 6 > rows (partially ordered): 6
SELECT * FROM TEST ORDER BY A, B OFFSET 3 ROWS FETCH NEXT 1 ROW WITH TIES; SELECT * FROM TEST ORDER BY A, B OFFSET 3 ROWS FETCH NEXT 1 ROW WITH TIES;
> A B C > A B C
...@@ -171,7 +171,7 @@ SELECT * FROM TEST ORDER BY A, B OFFSET 3 ROWS FETCH NEXT 1 ROW WITH TIES; ...@@ -171,7 +171,7 @@ SELECT * FROM TEST ORDER BY A, B OFFSET 3 ROWS FETCH NEXT 1 ROW WITH TIES;
> 1 2 1 > 1 2 1
> 1 2 2 > 1 2 2
> 1 2 3 > 1 2 3
> rows: 3 > rows (partially ordered): 3
SELECT * FROM TEST FETCH FIRST 1 ROW WITH TIES; SELECT * FROM TEST FETCH FIRST 1 ROW WITH TIES;
> exception WITH_TIES_WITHOUT_ORDER_BY > exception WITH_TIES_WITHOUT_ORDER_BY
...@@ -183,7 +183,7 @@ SELECT * FROM TEST FETCH FIRST 1 ROW WITH TIES; ...@@ -183,7 +183,7 @@ SELECT * FROM TEST FETCH FIRST 1 ROW WITH TIES;
> 1 2 2 > 1 2 2
> 1 2 3 > 1 2 3
> 1 2 4 > 1 2 4
> rows: 4 > rows (partially ordered): 4
(SELECT * FROM TEST) UNION (SELECT 1, 2, 4) ORDER BY A, B OFFSET 3 ROWS FETCH NEXT 50 PERCENT ROWS ONLY; (SELECT * FROM TEST) UNION (SELECT 1, 2, 4) ORDER BY A, B OFFSET 3 ROWS FETCH NEXT 50 PERCENT ROWS ONLY;
> A B C > A B C
...@@ -195,7 +195,7 @@ SELECT * FROM TEST FETCH FIRST 1 ROW WITH TIES; ...@@ -195,7 +195,7 @@ SELECT * FROM TEST FETCH FIRST 1 ROW WITH TIES;
> 2 1 1 > 2 1 1
> 2 1 2 > 2 1 2
> 2 1 3 > 2 1 3
> rows: 7 > rows (partially ordered): 7
(SELECT * FROM TEST) UNION (SELECT 1, 2, 4) ORDER BY A, B OFFSET 3 ROWS FETCH NEXT 40 PERCENT ROWS WITH TIES; (SELECT * FROM TEST) UNION (SELECT 1, 2, 4) ORDER BY A, B OFFSET 3 ROWS FETCH NEXT 40 PERCENT ROWS WITH TIES;
> A B C > A B C
...@@ -207,7 +207,7 @@ SELECT * FROM TEST FETCH FIRST 1 ROW WITH TIES; ...@@ -207,7 +207,7 @@ SELECT * FROM TEST FETCH FIRST 1 ROW WITH TIES;
> 2 1 1 > 2 1 1
> 2 1 2 > 2 1 2
> 2 1 3 > 2 1 3
> rows: 7 > rows (partially ordered): 7
(SELECT * FROM TEST) UNION (SELECT 1, 2, 4) FETCH NEXT 1 ROW WITH TIES; (SELECT * FROM TEST) UNION (SELECT 1, 2, 4) FETCH NEXT 1 ROW WITH TIES;
> exception WITH_TIES_WITHOUT_ORDER_BY > exception WITH_TIES_WITHOUT_ORDER_BY
...@@ -233,7 +233,7 @@ SELECT A, B FROM TEST ORDER BY A FETCH FIRST 1 ROW WITH TIES; ...@@ -233,7 +233,7 @@ SELECT A, B FROM TEST ORDER BY A FETCH FIRST 1 ROW WITH TIES;
> 0 1 > 0 1
> 0 3 > 0 3
> 0.0 2 > 0.0 2
> rows: 3 > rows (partially ordered): 3
DROP TABLE TEST; DROP TABLE TEST;
> ok > ok
......
...@@ -60,35 +60,35 @@ SHOW TABLES; ...@@ -60,35 +60,35 @@ SHOW TABLES;
> TABLE_NAME TABLE_SCHEMA > TABLE_NAME TABLE_SCHEMA
> ---------- ------------ > ---------- ------------
> TEST_P PUBLIC > TEST_P PUBLIC
> rows: 1 > rows (ordered): 1
SHOW TABLES FROM PUBLIC; SHOW TABLES FROM PUBLIC;
> TABLE_NAME TABLE_SCHEMA > TABLE_NAME TABLE_SCHEMA
> ---------- ------------ > ---------- ------------
> TEST_P PUBLIC > TEST_P PUBLIC
> rows: 1 > rows (ordered): 1
SHOW TABLES FROM SCH; SHOW TABLES FROM SCH;
> TABLE_NAME TABLE_SCHEMA > TABLE_NAME TABLE_SCHEMA
> ---------- ------------ > ---------- ------------
> TEST_S SCH > TEST_S SCH
> rows: 1 > rows (ordered): 1
SHOW COLUMNS FROM TEST_P; SHOW COLUMNS FROM TEST_P;
> FIELD TYPE NULL KEY DEFAULT > FIELD TYPE NULL KEY DEFAULT
> ----- ------------ ---- --- ------- > ----- ------------ ---- --- -------
> ID_P INTEGER(10) NO PRI NULL > ID_P INTEGER(10) NO PRI NULL
> N_P INTEGER(10) YES 1
> U_P VARCHAR(255) YES UNI NULL > U_P VARCHAR(255) YES UNI NULL
> rows: 3 > N_P INTEGER(10) YES 1
> rows (ordered): 3
SHOW COLUMNS FROM TEST_S FROM SCH; SHOW COLUMNS FROM TEST_S FROM SCH;
> FIELD TYPE NULL KEY DEFAULT > FIELD TYPE NULL KEY DEFAULT
> ----- ------------ ---- --- ------- > ----- ------------ ---- --- -------
> ID_S INTEGER(10) NO PRI NULL > ID_S INTEGER(10) NO PRI NULL
> N_S INTEGER(10) YES 1
> U_S VARCHAR(255) YES UNI NULL > U_S VARCHAR(255) YES UNI NULL
> rows: 3 > N_S INTEGER(10) YES 1
> rows (ordered): 3
SHOW DATABASES; SHOW DATABASES;
> SCHEMA_NAME > SCHEMA_NAME
......
...@@ -17,7 +17,7 @@ select array_agg(v order by v asc), ...@@ -17,7 +17,7 @@ select array_agg(v order by v asc),
> ARRAY_AGG(V ORDER BY V) ARRAY_AGG(V ORDER BY V DESC) FILTER (WHERE (V >= '4')) > ARRAY_AGG(V ORDER BY V) ARRAY_AGG(V ORDER BY V DESC) FILTER (WHERE (V >= '4'))
> ------------------------ ------------------------------------------------------ > ------------------------ ------------------------------------------------------
> (2, 3, 4, 5, 6, 7, 8, 9) (9, 8, 7, 6, 5, 4) > (2, 3, 4, 5, 6, 7, 8, 9) (9, 8, 7, 6, 5, 4)
> rows (ordered): 1 > rows: 1
create index test_idx on test(v); create index test_idx on test(v);
> ok > ok
...@@ -28,7 +28,7 @@ select ARRAY_AGG(v order by v asc), ...@@ -28,7 +28,7 @@ select ARRAY_AGG(v order by v asc),
> ARRAY_AGG(V ORDER BY V) ARRAY_AGG(V ORDER BY V DESC) FILTER (WHERE (V >= '4')) > ARRAY_AGG(V ORDER BY V) ARRAY_AGG(V ORDER BY V DESC) FILTER (WHERE (V >= '4'))
> ------------------------ ------------------------------------------------------ > ------------------------ ------------------------------------------------------
> (2, 3, 4, 5, 6, 7, 8, 9) (9, 8, 7, 6, 5, 4) > (2, 3, 4, 5, 6, 7, 8, 9) (9, 8, 7, 6, 5, 4)
> rows (ordered): 1 > rows: 1
select ARRAY_AGG(v order by v asc), select ARRAY_AGG(v order by v asc),
ARRAY_AGG(v order by v desc) filter (where v >= '4') ARRAY_AGG(v order by v desc) filter (where v >= '4')
...@@ -36,7 +36,7 @@ select ARRAY_AGG(v order by v asc), ...@@ -36,7 +36,7 @@ select ARRAY_AGG(v order by v asc),
> ARRAY_AGG(V ORDER BY V) ARRAY_AGG(V ORDER BY V DESC) FILTER (WHERE (V >= '4')) > ARRAY_AGG(V ORDER BY V) ARRAY_AGG(V ORDER BY V DESC) FILTER (WHERE (V >= '4'))
> --------------------------- ------------------------------------------------------ > --------------------------- ------------------------------------------------------
> (1, 2, 3, 4, 5, 6, 7, 8, 9) (9, 8, 7, 6, 5, 4) > (1, 2, 3, 4, 5, 6, 7, 8, 9) (9, 8, 7, 6, 5, 4)
> rows (ordered): 1 > rows: 1
drop table test; drop table test;
> ok > ok
...@@ -63,7 +63,7 @@ select array_agg(distinct v order by v desc) from test; ...@@ -63,7 +63,7 @@ select array_agg(distinct v order by v desc) from test;
> ARRAY_AGG(DISTINCT V ORDER BY V DESC) > ARRAY_AGG(DISTINCT V ORDER BY V DESC)
> ------------------------------------- > -------------------------------------
> (9, 8, 7, 3, 2, -1) > (9, 8, 7, 3, 2, -1)
> rows (ordered): 1 > rows: 1
drop table test; drop table test;
> ok > ok
...@@ -77,7 +77,7 @@ INSERT INTO TEST VALUES (1, 'a'), (2, 'a'), (3, 'b'), (4, 'c'), (5, 'c'), (6, 'c ...@@ -77,7 +77,7 @@ INSERT INTO TEST VALUES (1, 'a'), (2, 'a'), (3, 'b'), (4, 'c'), (5, 'c'), (6, 'c
SELECT ARRAY_AGG(ID), NAME FROM TEST; SELECT ARRAY_AGG(ID), NAME FROM TEST;
> exception MUST_GROUP_BY_COLUMN_1 > exception MUST_GROUP_BY_COLUMN_1
SELECT ARRAY_AGG(ID ORDER /**/ BY ID), NAME FROM TEST GROUP BY NAME; SELECT ARRAY_AGG(ID ORDER BY ID), NAME FROM TEST GROUP BY NAME;
> ARRAY_AGG(ID ORDER BY ID) NAME > ARRAY_AGG(ID ORDER BY ID) NAME
> ------------------------- ---- > ------------------------- ----
> (1, 2) a > (1, 2) a
...@@ -85,7 +85,7 @@ SELECT ARRAY_AGG(ID ORDER /**/ BY ID), NAME FROM TEST GROUP BY NAME; ...@@ -85,7 +85,7 @@ SELECT ARRAY_AGG(ID ORDER /**/ BY ID), NAME FROM TEST GROUP BY NAME;
> (4, 5, 6) c > (4, 5, 6) c
> rows: 3 > rows: 3
SELECT ARRAY_AGG(ID ORDER /**/ BY ID) OVER (), NAME FROM TEST; SELECT ARRAY_AGG(ID ORDER BY ID) OVER (), NAME FROM TEST;
> ARRAY_AGG(ID ORDER BY ID) OVER () NAME > ARRAY_AGG(ID ORDER BY ID) OVER () NAME
> --------------------------------- ---- > --------------------------------- ----
> (1, 2, 3, 4, 5, 6) a > (1, 2, 3, 4, 5, 6) a
...@@ -96,7 +96,7 @@ SELECT ARRAY_AGG(ID ORDER /**/ BY ID) OVER (), NAME FROM TEST; ...@@ -96,7 +96,7 @@ SELECT ARRAY_AGG(ID ORDER /**/ BY ID) OVER (), NAME FROM TEST;
> (1, 2, 3, 4, 5, 6) c > (1, 2, 3, 4, 5, 6) c
> rows: 6 > rows: 6
SELECT ARRAY_AGG(ID ORDER /**/ BY ID) OVER (PARTITION BY NAME), NAME FROM TEST; SELECT ARRAY_AGG(ID ORDER BY ID) OVER (PARTITION BY NAME), NAME FROM TEST;
> ARRAY_AGG(ID ORDER BY ID) OVER (PARTITION BY NAME) NAME > ARRAY_AGG(ID ORDER BY ID) OVER (PARTITION BY NAME) NAME
> -------------------------------------------------- ---- > -------------------------------------------------- ----
> (1, 2) a > (1, 2) a
...@@ -107,7 +107,7 @@ SELECT ARRAY_AGG(ID ORDER /**/ BY ID) OVER (PARTITION BY NAME), NAME FROM TEST; ...@@ -107,7 +107,7 @@ SELECT ARRAY_AGG(ID ORDER /**/ BY ID) OVER (PARTITION BY NAME), NAME FROM TEST;
> (4, 5, 6) c > (4, 5, 6) c
> rows: 6 > rows: 6
SELECT ARRAY_AGG(ID ORDER /**/ BY ID) FILTER (WHERE ID < 3 OR ID > 4) OVER (PARTITION BY NAME), NAME FROM TEST ORDER BY NAME; SELECT ARRAY_AGG(ID ORDER BY ID) FILTER (WHERE ID < 3 OR ID > 4) OVER (PARTITION BY NAME), NAME FROM TEST ORDER BY NAME;
> ARRAY_AGG(ID ORDER BY ID) FILTER (WHERE ((ID < 3) OR (ID > 4))) OVER (PARTITION BY NAME) NAME > ARRAY_AGG(ID ORDER BY ID) FILTER (WHERE ((ID < 3) OR (ID > 4))) OVER (PARTITION BY NAME) NAME
> ---------------------------------------------------------------------------------------- ---- > ---------------------------------------------------------------------------------------- ----
> (1, 2) a > (1, 2) a
...@@ -124,7 +124,7 @@ SELECT ARRAY_AGG(SUM(ID)) OVER () FROM TEST; ...@@ -124,7 +124,7 @@ SELECT ARRAY_AGG(SUM(ID)) OVER () FROM TEST;
> (21) > (21)
> rows: 1 > rows: 1
SELECT ARRAY_AGG(ID ORDER /**/ BY ID) OVER() FROM TEST GROUP BY ID ORDER /**/ BY ID; SELECT ARRAY_AGG(ID ORDER BY ID) OVER() FROM TEST GROUP BY ID ORDER BY ID;
> ARRAY_AGG(ID ORDER BY ID) OVER () > ARRAY_AGG(ID ORDER BY ID) OVER ()
> --------------------------------- > ---------------------------------
> (1, 2, 3, 4, 5, 6) > (1, 2, 3, 4, 5, 6)
...@@ -133,7 +133,7 @@ SELECT ARRAY_AGG(ID ORDER /**/ BY ID) OVER() FROM TEST GROUP BY ID ORDER /**/ BY ...@@ -133,7 +133,7 @@ SELECT ARRAY_AGG(ID ORDER /**/ BY ID) OVER() FROM TEST GROUP BY ID ORDER /**/ BY
> (1, 2, 3, 4, 5, 6) > (1, 2, 3, 4, 5, 6)
> (1, 2, 3, 4, 5, 6) > (1, 2, 3, 4, 5, 6)
> (1, 2, 3, 4, 5, 6) > (1, 2, 3, 4, 5, 6)
> rows: 6 > rows (ordered): 6
SELECT ARRAY_AGG(NAME) OVER(PARTITION BY NAME) FROM TEST GROUP BY NAME; SELECT ARRAY_AGG(NAME) OVER(PARTITION BY NAME) FROM TEST GROUP BY NAME;
> ARRAY_AGG(NAME) OVER (PARTITION BY NAME) > ARRAY_AGG(NAME) OVER (PARTITION BY NAME)
...@@ -143,7 +143,7 @@ SELECT ARRAY_AGG(NAME) OVER(PARTITION BY NAME) FROM TEST GROUP BY NAME; ...@@ -143,7 +143,7 @@ SELECT ARRAY_AGG(NAME) OVER(PARTITION BY NAME) FROM TEST GROUP BY NAME;
> (c) > (c)
> rows: 3 > rows: 3
SELECT ARRAY_AGG(ARRAY_AGG(ID ORDER /**/ BY ID)) OVER (PARTITION BY NAME), NAME FROM TEST GROUP BY NAME; SELECT ARRAY_AGG(ARRAY_AGG(ID ORDER BY ID)) OVER (PARTITION BY NAME), NAME FROM TEST GROUP BY NAME;
> ARRAY_AGG(ARRAY_AGG(ID ORDER BY ID)) OVER (PARTITION BY NAME) NAME > ARRAY_AGG(ARRAY_AGG(ID ORDER BY ID)) OVER (PARTITION BY NAME) NAME
> ------------------------------------------------------------- ---- > ------------------------------------------------------------- ----
> ((1, 2)) a > ((1, 2)) a
...@@ -151,13 +151,13 @@ SELECT ARRAY_AGG(ARRAY_AGG(ID ORDER /**/ BY ID)) OVER (PARTITION BY NAME), NAME ...@@ -151,13 +151,13 @@ SELECT ARRAY_AGG(ARRAY_AGG(ID ORDER /**/ BY ID)) OVER (PARTITION BY NAME), NAME
> ((4, 5, 6)) c > ((4, 5, 6)) c
> rows: 3 > rows: 3
SELECT ARRAY_AGG(ARRAY_AGG(ID ORDER /**/ BY ID)) OVER (PARTITION BY NAME), NAME FROM TEST SELECT ARRAY_AGG(ARRAY_AGG(ID ORDER BY ID)) OVER (PARTITION BY NAME), NAME FROM TEST
GROUP BY NAME ORDER /**/ BY NAME OFFSET 1 ROW; GROUP BY NAME ORDER BY NAME OFFSET 1 ROW;
> ARRAY_AGG(ARRAY_AGG(ID ORDER BY ID)) OVER (PARTITION BY NAME) NAME > ARRAY_AGG(ARRAY_AGG(ID ORDER BY ID)) OVER (PARTITION BY NAME) NAME
> ------------------------------------------------------------- ---- > ------------------------------------------------------------- ----
> ((3)) b > ((3)) b
> ((4, 5, 6)) c > ((4, 5, 6)) c
> rows: 2 > rows (ordered): 2
SELECT ARRAY_AGG(ARRAY_AGG(ID ORDER BY ID)) FILTER (WHERE NAME > 'b') OVER (PARTITION BY NAME), NAME FROM TEST SELECT ARRAY_AGG(ARRAY_AGG(ID ORDER BY ID)) FILTER (WHERE NAME > 'b') OVER (PARTITION BY NAME), NAME FROM TEST
GROUP BY NAME ORDER BY NAME; GROUP BY NAME ORDER BY NAME;
...@@ -196,7 +196,7 @@ SELECT ARRAY_AGG(ARRAY_AGG(ID ORDER BY ID)) FILTER (WHERE NAME > 'c') OVER () FR ...@@ -196,7 +196,7 @@ SELECT ARRAY_AGG(ARRAY_AGG(ID ORDER BY ID)) FILTER (WHERE NAME > 'c') OVER () FR
SELECT ARRAY_AGG(ID) OVER() FROM TEST GROUP BY NAME; SELECT ARRAY_AGG(ID) OVER() FROM TEST GROUP BY NAME;
> exception MUST_GROUP_BY_COLUMN_1 > exception MUST_GROUP_BY_COLUMN_1
SELECT ARRAY_AGG(ID) OVER(PARTITION BY NAME ORDER /**/ BY ID), NAME FROM TEST; SELECT ARRAY_AGG(ID) OVER(PARTITION BY NAME ORDER BY ID), NAME FROM TEST;
> ARRAY_AGG(ID) OVER (PARTITION BY NAME ORDER BY ID) NAME > ARRAY_AGG(ID) OVER (PARTITION BY NAME ORDER BY ID) NAME
> -------------------------------------------------- ---- > -------------------------------------------------- ----
> (1) a > (1) a
...@@ -207,7 +207,7 @@ SELECT ARRAY_AGG(ID) OVER(PARTITION BY NAME ORDER /**/ BY ID), NAME FROM TEST; ...@@ -207,7 +207,7 @@ SELECT ARRAY_AGG(ID) OVER(PARTITION BY NAME ORDER /**/ BY ID), NAME FROM TEST;
> (4, 5, 6) c > (4, 5, 6) c
> rows: 6 > rows: 6
SELECT ARRAY_AGG(ID) OVER(PARTITION BY NAME ORDER /**/ BY ID DESC), NAME FROM TEST; SELECT ARRAY_AGG(ID) OVER(PARTITION BY NAME ORDER BY ID DESC), NAME FROM TEST;
> ARRAY_AGG(ID) OVER (PARTITION BY NAME ORDER BY ID DESC) NAME > ARRAY_AGG(ID) OVER (PARTITION BY NAME ORDER BY ID DESC) NAME
> ------------------------------------------------------- ---- > ------------------------------------------------------- ----
> (2) a > (2) a
...@@ -219,8 +219,8 @@ SELECT ARRAY_AGG(ID) OVER(PARTITION BY NAME ORDER /**/ BY ID DESC), NAME FROM TE ...@@ -219,8 +219,8 @@ SELECT ARRAY_AGG(ID) OVER(PARTITION BY NAME ORDER /**/ BY ID DESC), NAME FROM TE
> rows: 6 > rows: 6
SELECT SELECT
ARRAY_AGG(ID ORDER /**/ BY ID) OVER(PARTITION BY NAME ORDER /**/ BY ID DESC) A, ARRAY_AGG(ID ORDER BY ID) OVER(PARTITION BY NAME ORDER BY ID DESC) A,
ARRAY_AGG(ID) OVER(PARTITION BY NAME ORDER /**/ BY ID DESC) D, ARRAY_AGG(ID) OVER(PARTITION BY NAME ORDER BY ID DESC) D,
NAME FROM TEST; NAME FROM TEST;
> A D NAME > A D NAME
> --------- --------- ---- > --------- --------- ----
...@@ -232,7 +232,7 @@ SELECT ...@@ -232,7 +232,7 @@ SELECT
> (6) (6) c > (6) (6) c
> rows: 6 > rows: 6
SELECT ARRAY_AGG(SUM(ID)) OVER(ORDER /**/ BY ID) FROM TEST GROUP BY ID; SELECT ARRAY_AGG(SUM(ID)) OVER(ORDER BY ID) FROM TEST GROUP BY ID;
> ARRAY_AGG(SUM(ID)) OVER (ORDER BY ID) > ARRAY_AGG(SUM(ID)) OVER (ORDER BY ID)
> ------------------------------------- > -------------------------------------
> (1) > (1)
...@@ -266,12 +266,12 @@ SELECT ...@@ -266,12 +266,12 @@ SELECT
FROM TEST; FROM TEST;
> D R G T N > D R G T N
> --------------- ------------ ------------ --------------- --------------- > --------------- ------------ ------------ --------------- ---------------
> (1, 2, 3, 4, 5) (2, 3, 4, 5) (2, 3, 4, 5) (1, 2, 3, 4, 5) (1, 2, 3, 4, 5)
> (1, 2, 3, 4, 5) (1, 3, 4, 5) (1, 5) (1, 2, 5) (1, 2, 3, 4, 5)
> (1, 2, 3, 4, 5) (1, 2, 4, 5) (1, 5) (1, 3, 5) (1, 2, 3, 4, 5)
> (1, 2, 3, 4, 5) (1, 2, 3, 5) (1, 5) (1, 4, 5) (1, 2, 3, 4, 5)
> (1, 2, 3, 4, 5) (1, 2, 3, 4) (1, 2, 3, 4) (1, 2, 3, 4, 5) (1, 2, 3, 4, 5) > (1, 2, 3, 4, 5) (1, 2, 3, 4) (1, 2, 3, 4) (1, 2, 3, 4, 5) (1, 2, 3, 4, 5)
> rows (ordered): 5 > (1, 2, 3, 4, 5) (1, 2, 3, 5) (1, 5) (1, 4, 5) (1, 2, 3, 4, 5)
> (1, 2, 3, 4, 5) (1, 2, 4, 5) (1, 5) (1, 3, 5) (1, 2, 3, 4, 5)
> (1, 2, 3, 4, 5) (1, 3, 4, 5) (1, 5) (1, 2, 5) (1, 2, 3, 4, 5)
> (1, 2, 3, 4, 5) (2, 3, 4, 5) (2, 3, 4, 5) (1, 2, 3, 4, 5) (1, 2, 3, 4, 5)
> rows: 5
DROP TABLE TEST; DROP TABLE TEST;
> ok > ok
...@@ -309,7 +309,7 @@ SELECT *, ...@@ -309,7 +309,7 @@ SELECT *,
> 6 8 (5, 6, 7) (8, 8, 9) (4, 5, 6, 7, 8) (8, 8, 8, 9, 9) (9, 9, 8, 8, 8) (3, 4, 5, 6, 7, 8) (5, 8, 8, 8, 9, 9) > 6 8 (5, 6, 7) (8, 8, 9) (4, 5, 6, 7, 8) (8, 8, 8, 9, 9) (9, 9, 8, 8, 8) (3, 4, 5, 6, 7, 8) (5, 8, 8, 8, 9, 9)
> 7 9 (6, 7, 8) (8, 9, 9) (4, 5, 6, 7, 8) (8, 8, 8, 9, 9) (9, 9, 8, 8, 8) (4, 5, 6, 7, 8) (8, 8, 8, 9, 9) > 7 9 (6, 7, 8) (8, 9, 9) (4, 5, 6, 7, 8) (8, 8, 8, 9, 9) (9, 9, 8, 8, 8) (4, 5, 6, 7, 8) (8, 8, 8, 9, 9)
> 8 9 (7, 8) (9, 9) (4, 5, 6, 7, 8) (8, 8, 8, 9, 9) (9, 9, 8, 8, 8) (4, 5, 6, 7, 8) (8, 8, 8, 9, 9) > 8 9 (7, 8) (9, 9) (4, 5, 6, 7, 8) (8, 8, 8, 9, 9) (9, 9, 8, 8, 8) (4, 5, 6, 7, 8) (8, 8, 8, 9, 9)
> rows (ordered): 8 > rows: 8
SELECT *, ARRAY_AGG(ID) OVER (ORDER BY VALUE ROWS -1 PRECEDING) FROM TEST; SELECT *, ARRAY_AGG(ID) OVER (ORDER BY VALUE ROWS -1 PRECEDING) FROM TEST;
> exception INVALID_VALUE_2 > exception INVALID_VALUE_2
...@@ -321,7 +321,7 @@ SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID ROWS BETWEEN 2 PRECEDING AND 1 PRECEDI ...@@ -321,7 +321,7 @@ SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID ROWS BETWEEN 2 PRECEDING AND 1 PRECEDI
> 2 1 (1) > 2 1 (1)
> 3 5 (1, 2) > 3 5 (1, 2)
> 4 8 (2, 3) > 4 8 (2, 3)
> rows (ordered): 4 > rows: 4
SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING) FROM TEST OFFSET 4 ROWS; SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING) FROM TEST OFFSET 4 ROWS;
> ID VALUE ARRAY_AGG(ID) OVER (ORDER BY ID ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING) > ID VALUE ARRAY_AGG(ID) OVER (ORDER BY ID ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING)
...@@ -330,7 +330,7 @@ SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWI ...@@ -330,7 +330,7 @@ SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWI
> 6 8 (7, 8) > 6 8 (7, 8)
> 7 9 (8) > 7 9 (8)
> 8 9 null > 8 9 null
> rows (ordered): 4 > rows: 4
SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING) FROM TEST FETCH FIRST 4 ROWS ONLY; SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING) FROM TEST FETCH FIRST 4 ROWS ONLY;
> ID VALUE ARRAY_AGG(ID) OVER (ORDER BY ID RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING) > ID VALUE ARRAY_AGG(ID) OVER (ORDER BY ID RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING)
...@@ -339,7 +339,7 @@ SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID RANGE BETWEEN 2 PRECEDING AND 1 PRECED ...@@ -339,7 +339,7 @@ SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID RANGE BETWEEN 2 PRECEDING AND 1 PRECED
> 2 1 (1) > 2 1 (1)
> 3 5 (1, 2) > 3 5 (1, 2)
> 4 8 (2, 3) > 4 8 (2, 3)
> rows (ordered): 4 > rows: 4
SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING) FROM TEST OFFSET 4 ROWS; SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING) FROM TEST OFFSET 4 ROWS;
> ID VALUE ARRAY_AGG(ID) OVER (ORDER BY ID RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING) > ID VALUE ARRAY_AGG(ID) OVER (ORDER BY ID RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING)
...@@ -348,7 +348,7 @@ SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOW ...@@ -348,7 +348,7 @@ SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOW
> 6 8 (7, 8) > 6 8 (7, 8)
> 7 9 (8) > 7 9 (8)
> 8 9 null > 8 9 null
> rows (ordered): 4 > rows: 4
SELECT *, SELECT *,
ARRAY_AGG(ID) OVER (ORDER BY VALUE GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) U_P, ARRAY_AGG(ID) OVER (ORDER BY VALUE GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) U_P,
...@@ -366,7 +366,7 @@ SELECT *, ...@@ -366,7 +366,7 @@ SELECT *,
> 6 8 (1, 2, 3) (1, 2, 3) (7, 8) (7, 8) > 6 8 (1, 2, 3) (1, 2, 3) (7, 8) (7, 8)
> 7 9 (1, 2, 3, 4, 5, 6) (3, 4, 5, 6) null null > 7 9 (1, 2, 3, 4, 5, 6) (3, 4, 5, 6) null null
> 8 9 (1, 2, 3, 4, 5, 6) (3, 4, 5, 6) null null > 8 9 (1, 2, 3, 4, 5, 6) (3, 4, 5, 6) null null
> rows (ordered): 8 > rows: 8
SELECT *, SELECT *,
ARRAY_AGG(ID) OVER (ORDER BY VALUE GROUPS BETWEEN 1 PRECEDING AND 0 PRECEDING) P, ARRAY_AGG(ID) OVER (ORDER BY VALUE GROUPS BETWEEN 1 PRECEDING AND 0 PRECEDING) P,
...@@ -382,7 +382,7 @@ SELECT *, ...@@ -382,7 +382,7 @@ SELECT *,
> 6 8 (3, 4, 5, 6) (4, 5, 6, 7, 8) > 6 8 (3, 4, 5, 6) (4, 5, 6, 7, 8)
> 7 9 (4, 5, 6, 7, 8) (7, 8) > 7 9 (4, 5, 6, 7, 8) (7, 8)
> 8 9 (4, 5, 6, 7, 8) (7, 8) > 8 9 (4, 5, 6, 7, 8) (7, 8)
> rows (ordered): 8 > rows: 8
SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID RANGE BETWEEN CURRENT ROW AND 1 PRECEDING) FROM TEST; SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID RANGE BETWEEN CURRENT ROW AND 1 PRECEDING) FROM TEST;
> exception SYNTAX_ERROR_1 > exception SYNTAX_ERROR_1
...@@ -415,7 +415,7 @@ SELECT *, ARRAY_AGG(ID) OVER (ORDER BY VALUE RANGE BETWEEN 2 PRECEDING AND 1 PRE ...@@ -415,7 +415,7 @@ SELECT *, ARRAY_AGG(ID) OVER (ORDER BY VALUE RANGE BETWEEN 2 PRECEDING AND 1 PRE
> 6 3 (1, 2, 3, 4) > 6 3 (1, 2, 3, 4)
> 7 4 (3, 4, 5, 6) > 7 4 (3, 4, 5, 6)
> 8 4 (3, 4, 5, 6) > 8 4 (3, 4, 5, 6)
> rows (ordered): 8 > rows: 8
SELECT *, ARRAY_AGG(ID) OVER (ORDER BY VALUE RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING) FROM TEST; SELECT *, ARRAY_AGG(ID) OVER (ORDER BY VALUE RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING) FROM TEST;
> ID VALUE ARRAY_AGG(ID) OVER (ORDER BY VALUE RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING) > ID VALUE ARRAY_AGG(ID) OVER (ORDER BY VALUE RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING)
...@@ -428,7 +428,7 @@ SELECT *, ARRAY_AGG(ID) OVER (ORDER BY VALUE RANGE BETWEEN 1 FOLLOWING AND 2 FOL ...@@ -428,7 +428,7 @@ SELECT *, ARRAY_AGG(ID) OVER (ORDER BY VALUE RANGE BETWEEN 1 FOLLOWING AND 2 FOL
> 6 3 (7, 8) > 6 3 (7, 8)
> 7 4 null > 7 4 null
> 8 4 null > 8 4 null
> rows (ordered): 8 > rows: 8
DROP TABLE TEST; DROP TABLE TEST;
> ok > ok
...@@ -60,7 +60,7 @@ SELECT COUNT(ID) OVER (ORDER BY NAME) AS NR, ...@@ -60,7 +60,7 @@ SELECT COUNT(ID) OVER (ORDER BY NAME) AS NR,
> -- -- > -- --
> 1 3 > 1 3
> 2 1 > 2 1
> rows (ordered): 2 > rows: 2
SELECT NR FROM (SELECT COUNT(ID) OVER (ORDER BY NAME) AS NR, SELECT NR FROM (SELECT COUNT(ID) OVER (ORDER BY NAME) AS NR,
A.ID AS ID FROM (SELECT ID, NAME FROM TEST ORDER BY NAME) AS A) A.ID AS ID FROM (SELECT ID, NAME FROM TEST ORDER BY NAME) AS A)
...@@ -82,7 +82,7 @@ SELECT I, V, COUNT(V) OVER W C, COUNT(DISTINCT V) OVER W D FROM ...@@ -82,7 +82,7 @@ SELECT I, V, COUNT(V) OVER W C, COUNT(DISTINCT V) OVER W D FROM
> 5 2 5 2 > 5 2 5 2
> 6 2 6 2 > 6 2 6 2
> 7 3 7 3 > 7 3 7 3
> rows (ordered): 7 > rows: 7
SELECT I, C, COUNT(I) OVER (PARTITION BY C) CNT FROM SELECT I, C, COUNT(I) OVER (PARTITION BY C) CNT FROM
VALUES (1, 1), (2, 1), (3, 2), (4, 2), (5, 2) T(I, C); VALUES (1, 1), (2, 1), (3, 2), (4, 2), (5, 2) T(I, C);
......
...@@ -17,7 +17,7 @@ select group_concat(v order by v asc separator '-'), ...@@ -17,7 +17,7 @@ select group_concat(v order by v asc separator '-'),
> GROUP_CONCAT(V ORDER BY V SEPARATOR '-') GROUP_CONCAT(V ORDER BY V DESC SEPARATOR '-') FILTER (WHERE (V >= '4')) > GROUP_CONCAT(V ORDER BY V SEPARATOR '-') GROUP_CONCAT(V ORDER BY V DESC SEPARATOR '-') FILTER (WHERE (V >= '4'))
> ---------------------------------------- ----------------------------------------------------------------------- > ---------------------------------------- -----------------------------------------------------------------------
> 2-3-4-5-6-7-8-9 9-8-7-6-5-4 > 2-3-4-5-6-7-8-9 9-8-7-6-5-4
> rows (ordered): 1 > rows: 1
create index test_idx on test(v); create index test_idx on test(v);
> ok > ok
...@@ -28,7 +28,7 @@ select group_concat(v order by v asc separator '-'), ...@@ -28,7 +28,7 @@ select group_concat(v order by v asc separator '-'),
> GROUP_CONCAT(V ORDER BY V SEPARATOR '-') GROUP_CONCAT(V ORDER BY V DESC SEPARATOR '-') FILTER (WHERE (V >= '4')) > GROUP_CONCAT(V ORDER BY V SEPARATOR '-') GROUP_CONCAT(V ORDER BY V DESC SEPARATOR '-') FILTER (WHERE (V >= '4'))
> ---------------------------------------- ----------------------------------------------------------------------- > ---------------------------------------- -----------------------------------------------------------------------
> 2-3-4-5-6-7-8-9 9-8-7-6-5-4 > 2-3-4-5-6-7-8-9 9-8-7-6-5-4
> rows (ordered): 1 > rows: 1
select group_concat(v order by v asc separator '-'), select group_concat(v order by v asc separator '-'),
group_concat(v order by v desc separator '-') filter (where v >= '4') group_concat(v order by v desc separator '-') filter (where v >= '4')
...@@ -36,7 +36,7 @@ select group_concat(v order by v asc separator '-'), ...@@ -36,7 +36,7 @@ select group_concat(v order by v asc separator '-'),
> GROUP_CONCAT(V ORDER BY V SEPARATOR '-') GROUP_CONCAT(V ORDER BY V DESC SEPARATOR '-') FILTER (WHERE (V >= '4')) > GROUP_CONCAT(V ORDER BY V SEPARATOR '-') GROUP_CONCAT(V ORDER BY V DESC SEPARATOR '-') FILTER (WHERE (V >= '4'))
> ---------------------------------------- ----------------------------------------------------------------------- > ---------------------------------------- -----------------------------------------------------------------------
> 1-2-3-4-5-6-7-8-9 9-8-7-6-5-4 > 1-2-3-4-5-6-7-8-9 9-8-7-6-5-4
> rows (ordered): 1 > rows: 1
drop table test; drop table test;
> ok > ok
...@@ -63,7 +63,7 @@ select group_concat(distinct v order by v desc) from test; ...@@ -63,7 +63,7 @@ select group_concat(distinct v order by v desc) from test;
> GROUP_CONCAT(DISTINCT V ORDER BY V DESC) > GROUP_CONCAT(DISTINCT V ORDER BY V DESC)
> ---------------------------------------- > ----------------------------------------
> 9,8,7,3,2,-1 > 9,8,7,3,2,-1
> rows (ordered): 1 > rows: 1
drop table test; drop table test;
> ok > ok
...@@ -80,7 +80,7 @@ SELECT ...@@ -80,7 +80,7 @@ SELECT
> 6 21 21 21 36 > 6 21 21 21 36
> 7 28 28 15 36 > 7 28 28 15 36
> 8 36 36 8 36 > 8 36 36 8 36
> rows (ordered): 8 > rows: 8
SELECT I, V, SUM(V) OVER W S, SUM(DISTINCT V) OVER W D FROM SELECT I, V, SUM(V) OVER W S, SUM(DISTINCT V) OVER W D FROM
VALUES (1, 1), (2, 1), (3, 1), (4, 1), (5, 2), (6, 2), (7, 3) T(I, V) VALUES (1, 1), (2, 1), (3, 1), (4, 1), (5, 2), (6, 2), (7, 3) T(I, V)
...@@ -94,4 +94,4 @@ SELECT I, V, SUM(V) OVER W S, SUM(DISTINCT V) OVER W D FROM ...@@ -94,4 +94,4 @@ SELECT I, V, SUM(V) OVER W S, SUM(DISTINCT V) OVER W D FROM
> 5 2 6 3 > 5 2 6 3
> 6 2 8 3 > 6 2 8 3
> 7 3 11 6 > 7 3 11 6
> rows (ordered): 7 > rows: 7
...@@ -37,7 +37,7 @@ SELECT *, ...@@ -37,7 +37,7 @@ SELECT *,
> 7 22 33 33 33 21 21 21 > 7 22 33 33 33 21 21 21
> 8 33 null null null 22 22 22 > 8 33 null null null 22 22 22
> 9 null null null null 33 33 33 > 9 null null null null 33 33 33
> rows (ordered): 9 > rows: 9
SELECT *, SELECT *,
LEAD(VALUE, 1) OVER (ORDER BY ID) LD, LEAD(VALUE, 1) OVER (ORDER BY ID) LD,
...@@ -58,7 +58,7 @@ SELECT *, ...@@ -58,7 +58,7 @@ SELECT *,
> 7 22 33 33 33 21 21 21 > 7 22 33 33 33 21 21 21
> 8 33 null null null 22 22 22 > 8 33 null null null 22 22 22
> 9 null null null null 33 33 33 > 9 null null null null 33 33 33
> rows (ordered): 9 > rows: 9
SELECT *, SELECT *,
LEAD(VALUE, 0) OVER (ORDER BY ID) LD, LEAD(VALUE, 0) OVER (ORDER BY ID) LD,
...@@ -79,7 +79,7 @@ SELECT *, ...@@ -79,7 +79,7 @@ SELECT *,
> 7 22 22 22 22 22 22 22 > 7 22 22 22 22 22 22 22
> 8 33 33 33 33 33 33 33 > 8 33 33 33 33 33 33 33
> 9 null null null null null null null > 9 null null null null null null null
> rows (ordered): 9 > rows: 9
SELECT *, SELECT *,
LEAD(VALUE, 2) OVER (ORDER BY ID) LD, LEAD(VALUE, 2) OVER (ORDER BY ID) LD,
...@@ -100,7 +100,7 @@ SELECT *, ...@@ -100,7 +100,7 @@ SELECT *,
> 7 22 null null null null null 13 > 7 22 null null null null null 13
> 8 33 null null null 21 21 21 > 8 33 null null null 21 21 21
> 9 null null null null 22 22 22 > 9 null null null null 22 22 22
> rows (ordered): 9 > rows: 9
SELECT *, SELECT *,
LEAD(VALUE, 2, 1111.0) OVER (ORDER BY ID) LD, LEAD(VALUE, 2, 1111.0) OVER (ORDER BY ID) LD,
...@@ -121,7 +121,7 @@ SELECT *, ...@@ -121,7 +121,7 @@ SELECT *,
> 7 22 null null 1111 null null 13 > 7 22 null null 1111 null null 13
> 8 33 1111 1111 1111 21 21 21 > 8 33 1111 1111 1111 21 21 21
> 9 null 1111 1111 1111 22 22 22 > 9 null 1111 1111 1111 22 22 22
> rows (ordered): 9 > rows: 9
SELECT LEAD(VALUE, -1) OVER (ORDER BY ID) FROM TEST; SELECT LEAD(VALUE, -1) OVER (ORDER BY ID) FROM TEST;
> exception INVALID_VALUE_2 > exception INVALID_VALUE_2
...@@ -144,7 +144,7 @@ SELECT LAG(VALUE) OVER (ORDER BY ID RANGE CURRENT ROW) FROM TEST; ...@@ -144,7 +144,7 @@ SELECT LAG(VALUE) OVER (ORDER BY ID RANGE CURRENT ROW) FROM TEST;
DROP TABLE TEST; DROP TABLE TEST;
> ok > ok
SELECT C, SUM(I) S, LEAD(SUM(I)) OVER (ORDER /**/ BY SUM(I)) L FROM SELECT C, SUM(I) S, LEAD(SUM(I)) OVER (ORDER BY SUM(I)) L FROM
VALUES (1, 1), (2, 1), (4, 2), (8, 2) T(I, C) GROUP BY C; VALUES (1, 1), (2, 1), (4, 2), (8, 2) T(I, C) GROUP BY C;
> C S L > C S L
> - -- ---- > - -- ----
......
...@@ -44,7 +44,7 @@ SELECT *, ...@@ -44,7 +44,7 @@ SELECT *,
> 4 1 13 null null 12 13 13 13 > 4 1 13 null null 12 13 13 13
> 5 1 null null null 12 null null 13 > 5 1 null null null 12 null null 13
> 6 1 13 null null 12 13 13 13 > 6 1 13 null null 12 13 13 13
> rows (ordered): 6 > rows: 6
SELECT *, SELECT *,
FIRST_VALUE(VALUE) OVER (ORDER BY ID) FIRST, FIRST_VALUE(VALUE) OVER (ORDER BY ID) FIRST,
...@@ -59,7 +59,7 @@ SELECT *, ...@@ -59,7 +59,7 @@ SELECT *,
> 2 1 12 12 12 12 12 12 12 > 2 1 12 12 12 12 12 12 12
> 3 1 null 12 12 12 null null 12 > 3 1 null 12 12 12 null null 12
> 4 1 13 12 12 12 13 13 13 > 4 1 13 12 12 12 13 13 13
> rows (ordered): 3 > rows: 3
SELECT *, SELECT *,
NTH_VALUE(VALUE, 2) OVER (ORDER BY ID) NTH, NTH_VALUE(VALUE, 2) OVER (ORDER BY ID) NTH,
...@@ -80,7 +80,7 @@ SELECT *, ...@@ -80,7 +80,7 @@ SELECT *,
> 4 1 13 12 12 null 12 12 null 13 13 12 > 4 1 13 12 12 null 12 12 null 13 13 12
> 5 1 null 12 12 13 12 12 13 13 13 12 > 5 1 null 12 12 13 12 12 13 13 13 12
> 6 1 13 12 12 null 12 12 null 13 13 13 > 6 1 13 12 12 null 12 12 null 13 13 13
> rows (ordered): 6 > rows: 6
SELECT *, SELECT *,
NTH_VALUE(VALUE, 2) OVER(ORDER BY ID) F, NTH_VALUE(VALUE, 2) OVER(ORDER BY ID) F,
...@@ -92,7 +92,7 @@ SELECT *, ...@@ -92,7 +92,7 @@ SELECT *,
NTH_VALUE(VALUE, 2) FROM LAST OVER(ORDER BY ID RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) L_U_C, NTH_VALUE(VALUE, 2) FROM LAST OVER(ORDER BY ID RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) L_U_C,
NTH_VALUE(VALUE, 2) FROM LAST OVER(ORDER BY ID RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) L_C_U, NTH_VALUE(VALUE, 2) FROM LAST OVER(ORDER BY ID RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) L_C_U,
NTH_VALUE(VALUE, 2) FROM LAST OVER(ORDER BY ID RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) L_U_U NTH_VALUE(VALUE, 2) FROM LAST OVER(ORDER BY ID RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) L_U_U
FROM TEST; FROM TEST ORDER BY ID;
> ID CATEGORY VALUE F F_U_C F_C_U F_U_U L L_U_C L_C_U L_U_U > ID CATEGORY VALUE F F_U_C F_C_U F_U_U L L_U_C L_C_U L_U_U
> -- -------- ----- ---- ----- ----- ----- ---- ----- ----- ----- > -- -------- ----- ---- ----- ----- ----- ---- ----- ----- -----
> 1 1 null null null 12 12 null null 41 41 > 1 1 null null null 12 12 null null 41 41
...@@ -117,7 +117,7 @@ SELECT *, ...@@ -117,7 +117,7 @@ SELECT *,
FIRST_VALUE(VALUE) OVER (PARTITION BY CATEGORY ORDER BY ID) FIRST, FIRST_VALUE(VALUE) OVER (PARTITION BY CATEGORY ORDER BY ID) FIRST,
LAST_VALUE(VALUE) OVER (PARTITION BY CATEGORY ORDER BY ID) LAST, LAST_VALUE(VALUE) OVER (PARTITION BY CATEGORY ORDER BY ID) LAST,
NTH_VALUE(VALUE, 2) OVER (PARTITION BY CATEGORY ORDER BY ID) NTH NTH_VALUE(VALUE, 2) OVER (PARTITION BY CATEGORY ORDER BY ID) NTH
FROM TEST; FROM TEST ORDER BY ID;
> ID CATEGORY VALUE FIRST LAST NTH > ID CATEGORY VALUE FIRST LAST NTH
> -- -------- ----- ----- ---- ---- > -- -------- ----- ----- ---- ----
> 1 1 null null null null > 1 1 null null null null
...@@ -144,7 +144,7 @@ SELECT ID, CATEGORY, ...@@ -144,7 +144,7 @@ SELECT ID, CATEGORY,
> 1 1 null null > 1 1 null null
> 2 1 1 null > 2 1 1 null
> 3 1 1 1 > 3 1 1 1
> rows (ordered): 3 > rows: 3
DROP TABLE TEST; DROP TABLE TEST;
> ok > ok
...@@ -17,16 +17,16 @@ SELECT NTILE(1) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 2)); ...@@ -17,16 +17,16 @@ SELECT NTILE(1) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 2));
> -------------------------- > --------------------------
> 1 > 1
> 1 > 1
> rows (ordered): 2 > rows: 2
SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 2)); SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 2)) ORDER BY X;
> NTILE(2) OVER (ORDER BY X) > NTILE(2) OVER (ORDER BY X)
> -------------------------- > --------------------------
> 1 > 1
> 2 > 2
> rows (ordered): 2 > rows (ordered): 2
SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 3)); SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 3)) ORDER BY X;
> NTILE(2) OVER (ORDER BY X) > NTILE(2) OVER (ORDER BY X)
> -------------------------- > --------------------------
> 1 > 1
...@@ -34,7 +34,7 @@ SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 3)); ...@@ -34,7 +34,7 @@ SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 3));
> 2 > 2
> rows (ordered): 3 > rows (ordered): 3
SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 4)); SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 4)) ORDER BY X;
> NTILE(2) OVER (ORDER BY X) > NTILE(2) OVER (ORDER BY X)
> -------------------------- > --------------------------
> 1 > 1
...@@ -43,7 +43,7 @@ SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 4)); ...@@ -43,7 +43,7 @@ SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 4));
> 2 > 2
> rows (ordered): 4 > rows (ordered): 4
SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 5)); SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 5)) ORDER BY X;
> NTILE(2) OVER (ORDER BY X) > NTILE(2) OVER (ORDER BY X)
> -------------------------- > --------------------------
> 1 > 1
...@@ -53,7 +53,7 @@ SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 5)); ...@@ -53,7 +53,7 @@ SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 5));
> 2 > 2
> rows (ordered): 5 > rows (ordered): 5
SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 6)); SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 6)) ORDER BY X;
> NTILE(2) OVER (ORDER BY X) > NTILE(2) OVER (ORDER BY X)
> -------------------------- > --------------------------
> 1 > 1
...@@ -64,7 +64,7 @@ SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 6)); ...@@ -64,7 +64,7 @@ SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 6));
> 2 > 2
> rows (ordered): 6 > rows (ordered): 6
SELECT NTILE(10) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 3)); SELECT NTILE(10) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 3)) ORDER BY X;
> NTILE(10) OVER (ORDER BY X) > NTILE(10) OVER (ORDER BY X)
> --------------------------- > ---------------------------
> 1 > 1
...@@ -72,7 +72,7 @@ SELECT NTILE(10) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 3)); ...@@ -72,7 +72,7 @@ SELECT NTILE(10) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 3));
> 3 > 3
> rows (ordered): 3 > rows (ordered): 3
SELECT NTILE(10) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 22)); SELECT NTILE(10) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 22)) ORDER BY X;
> NTILE(10) OVER (ORDER BY X) > NTILE(10) OVER (ORDER BY X)
> --------------------------- > ---------------------------
> 1 > 1
...@@ -102,7 +102,7 @@ SELECT NTILE(10) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 22)); ...@@ -102,7 +102,7 @@ SELECT NTILE(10) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 22));
SELECT NTILE(0) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 1)); SELECT NTILE(0) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 1));
> exception INVALID_VALUE_2 > exception INVALID_VALUE_2
SELECT NTILE(X) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 6)); SELECT NTILE(X) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 6)) ORDER BY X;
> NTILE(X) OVER (ORDER BY X) > NTILE(X) OVER (ORDER BY X)
> -------------------------- > --------------------------
> 1 > 1
......
...@@ -41,7 +41,7 @@ SELECT *, ...@@ -41,7 +41,7 @@ SELECT *,
> 7 3 32 7 0.0 1.0 7 7 7 0.75 0.78 > 7 3 32 7 0.0 1.0 7 7 7 0.75 0.78
> 8 3 33 8 0.0 1.0 8 8 8 0.88 0.89 > 8 3 33 8 0.0 1.0 8 8 8 0.88 0.89
> 9 4 41 9 0.0 1.0 9 9 9 1.0 1.0 > 9 4 41 9 0.0 1.0 9 9 9 1.0 1.0
> rows (ordered): 9 > rows: 9
SELECT *, SELECT *,
ROW_NUMBER() OVER (ORDER BY CATEGORY) RN, ROW_NUMBER() OVER (ORDER BY CATEGORY) RN,
...@@ -61,7 +61,7 @@ SELECT *, ...@@ -61,7 +61,7 @@ SELECT *,
> 7 3 32 7 6 3 0.63 0.89 > 7 3 32 7 6 3 0.63 0.89
> 8 3 33 8 6 3 0.63 0.89 > 8 3 33 8 6 3 0.63 0.89
> 9 4 41 9 9 4 1.0 1.0 > 9 4 41 9 9 4 1.0 1.0
> rows (ordered): 9 > rows: 9
SELECT *, SELECT *,
ROW_NUMBER() OVER (PARTITION BY CATEGORY ORDER BY ID) RN, ROW_NUMBER() OVER (PARTITION BY CATEGORY ORDER BY ID) RN,
...@@ -81,7 +81,7 @@ SELECT *, ...@@ -81,7 +81,7 @@ SELECT *,
> 7 3 32 2 2 2 0.5 0.67 > 7 3 32 2 2 2 0.5 0.67
> 8 3 33 3 3 3 1.0 1.0 > 8 3 33 3 3 3 1.0 1.0
> 9 4 41 1 1 1 0.0 1.0 > 9 4 41 1 1 1 0.0 1.0
> rows (ordered): 9 > rows: 9
SELECT SELECT
ROW_NUMBER() OVER (ORDER BY CATEGORY) RN, ROW_NUMBER() OVER (ORDER BY CATEGORY) RN,
...@@ -133,7 +133,7 @@ INSERT INTO TEST VALUES ...@@ -133,7 +133,7 @@ INSERT INTO TEST VALUES
(4, 'b', 8); (4, 'b', 8);
> update count: 4 > update count: 4
SELECT ROW_NUMBER() OVER (ORDER /**/ BY TYPE) RN, TYPE, SUM(CNT) SUM FROM TEST GROUP BY TYPE; SELECT ROW_NUMBER() OVER (ORDER BY TYPE) RN, TYPE, SUM(CNT) SUM FROM TEST GROUP BY TYPE;
> RN TYPE SUM > RN TYPE SUM
> -- ---- --- > -- ---- ---
> 1 a 1 > 1 a 1
......
...@@ -10,7 +10,7 @@ select * from test where id in (select id from test order by 'x'); ...@@ -10,7 +10,7 @@ select * from test where id in (select id from test order by 'x');
> ID > ID
> -- > --
> 1 > 1
> rows (ordered): 1 > rows: 1
drop table test; drop table test;
> ok > ok
...@@ -63,7 +63,7 @@ AND studentID = 2; ...@@ -63,7 +63,7 @@ AND studentID = 2;
> SUM(POINTS) > SUM(POINTS)
> ----------- > -----------
> 30 > 30
> rows (ordered): 1 > rows: 1
SELECT eventID X FROM RESULTS SELECT eventID X FROM RESULTS
WHERE studentID = 2 WHERE studentID = 2
...@@ -85,7 +85,7 @@ AND studentID = 2; ...@@ -85,7 +85,7 @@ AND studentID = 2;
> SUM(R.POINTS) > SUM(R.POINTS)
> ------------- > -------------
> 30 > 30
> rows (ordered): 1 > rows: 1
drop table results; drop table results;
> ok > ok
...@@ -97,7 +97,7 @@ create table test(id int, name varchar) as select 1, 'a'; ...@@ -97,7 +97,7 @@ create table test(id int, name varchar) as select 1, 'a';
> ID > ID
> -- > --
> 1 > 1
> rows (ordered): 1 > rows: 1
drop table test; drop table test;
> ok > ok
...@@ -162,7 +162,7 @@ select id from test where name in(null, null); ...@@ -162,7 +162,7 @@ select id from test where name in(null, null);
select * from (select * from test order by name limit 1) where id < 10; select * from (select * from test order by name limit 1) where id < 10;
> ID NAME > ID NAME
> -- ---- > -- ----
> rows (ordered): 0 > rows: 0
drop table test; drop table test;
> ok > ok
...@@ -335,7 +335,7 @@ select * from dual where x in (select x from dual group by x order by max(x)); ...@@ -335,7 +335,7 @@ select * from dual where x in (select x from dual group by x order by max(x));
> X > X
> - > -
> 1 > 1
> rows (ordered): 1 > rows: 1
create table test(d decimal(1, 2)); create table test(d decimal(1, 2));
> exception INVALID_VALUE_SCALE_PRECISION > exception INVALID_VALUE_SCALE_PRECISION
...@@ -742,7 +742,7 @@ select * from(select 1 from system_range(1, 2) group by sin(x) order by sin(x)); ...@@ -742,7 +742,7 @@ select * from(select 1 from system_range(1, 2) group by sin(x) order by sin(x));
> - > -
> 1 > 1
> 1 > 1
> rows (ordered): 2 > rows: 2
create table parent as select 1 id, 2 x; create table parent as select 1 id, 2 x;
> ok > ok
...@@ -1190,7 +1190,7 @@ drop table p; ...@@ -1190,7 +1190,7 @@ drop table p;
> X > X
> - > -
> 1 > 1
> rows (ordered): 1 > rows: 1
create table test(a int, b int default 1); create table test(a int, b int default 1);
> ok > ok
...@@ -2813,7 +2813,7 @@ select rownum, * from (select * from test where id>1 order by id desc); ...@@ -2813,7 +2813,7 @@ select rownum, * from (select * from test where id>1 order by id desc);
> -------- -- ---- > -------- -- ----
> 1 3 33 > 1 3 33
> 2 2 22 > 2 2 22
> rows (ordered): 2 > rows: 2
update test set name='x' where rownum<2; update test set name='x' where rownum<2;
> update count: 1 > update count: 1
...@@ -3289,7 +3289,7 @@ select select a from test order by id; ...@@ -3289,7 +3289,7 @@ select select a from test order by id;
> SELECT A FROM PUBLIC.TEST /* PUBLIC.PRIMARY_KEY_2 */ /* scanCount: 2 */ ORDER BY =ID /* index sorted */ > SELECT A FROM PUBLIC.TEST /* PUBLIC.PRIMARY_KEY_2 */ /* scanCount: 2 */ ORDER BY =ID /* index sorted */
> ------------------------------------------------------------------------------------------------------- > -------------------------------------------------------------------------------------------------------
> TRUE > TRUE
> rows (ordered): 1 > rows: 1
insert into test values(2, 'N'); insert into test values(2, 'N');
> update count: 1 > update count: 1
...@@ -6676,7 +6676,7 @@ SELECT GROUP_CONCAT(ID ORDER BY ID) FROM TEST; ...@@ -6676,7 +6676,7 @@ SELECT GROUP_CONCAT(ID ORDER BY ID) FROM TEST;
> GROUP_CONCAT(ID ORDER BY ID) > GROUP_CONCAT(ID ORDER BY ID)
> ---------------------------- > ----------------------------
> 1,2,3,4,5,6,7,8,9 > 1,2,3,4,5,6,7,8,9
> rows (ordered): 1 > rows: 1
SELECT STRING_AGG(ID,';') FROM TEST; SELECT STRING_AGG(ID,';') FROM TEST;
> GROUP_CONCAT(ID SEPARATOR ';') > GROUP_CONCAT(ID SEPARATOR ';')
...@@ -7945,9 +7945,9 @@ insert into test values (2014, 'execution'), (2015, 'execution'), (2016, 'execut ...@@ -7945,9 +7945,9 @@ insert into test values (2014, 'execution'), (2015, 'execution'), (2016, 'execut
select * from test where year in (select distinct year from test order by year desc limit 1 offset 0); select * from test where year in (select distinct year from test order by year desc limit 1 offset 0);
> YEAR ACTION > YEAR ACTION
> ---- --------- > ---- ---------
> 2016 order
> 2016 execution > 2016 execution
> rows (ordered): 2 > 2016 order
> rows: 2
drop table test; drop table test;
> ok > ok
......
...@@ -27,7 +27,7 @@ SELECT *, ROW_NUMBER() OVER W1, ROW_NUMBER() OVER W2 FROM TEST ...@@ -27,7 +27,7 @@ SELECT *, ROW_NUMBER() OVER W1, ROW_NUMBER() OVER W2 FROM TEST
> 2 3 1 2 1 > 2 3 1 2 1
> 3 2 2 1 2 > 3 2 2 1 2
> 4 1 2 2 1 > 4 1 2 2 1
> rows (ordered): 4 > rows: 4
SELECT *, LAST_VALUE(ID) OVER W FROM TEST SELECT *, LAST_VALUE(ID) OVER W FROM TEST
WINDOW W AS (PARTITION BY CATEGORY ORDER BY ID RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW); WINDOW W AS (PARTITION BY CATEGORY ORDER BY ID RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW);
...@@ -37,7 +37,7 @@ SELECT *, LAST_VALUE(ID) OVER W FROM TEST ...@@ -37,7 +37,7 @@ SELECT *, LAST_VALUE(ID) OVER W FROM TEST
> 2 3 1 1 > 2 3 1 1
> 3 2 2 4 > 3 2 2 4
> 4 1 2 3 > 4 1 2 3
> rows (ordered): 4 > rows: 4
DROP TABLE TEST; DROP TABLE TEST;
> ok > ok
...@@ -75,7 +75,7 @@ SELECT ROW_NUMBER() OVER (ORDER /**/ BY CATEGORY), SUM(ID) FROM TEST GROUP BY C ...@@ -75,7 +75,7 @@ SELECT ROW_NUMBER() OVER (ORDER /**/ BY CATEGORY), SUM(ID) FROM TEST GROUP BY C
> 1 12 > 1 12
> rows: 1 > rows: 1
SELECT ROW_NUMBER() OVER (ORDER /**/ BY CATEGORY), SUM(ID) FROM TEST GROUP BY CATEGORY HAVING CATEGORY > 1; SELECT ROW_NUMBER() OVER (ORDER BY CATEGORY), SUM(ID) FROM TEST GROUP BY CATEGORY HAVING CATEGORY > 1;
> ROW_NUMBER() OVER (ORDER BY CATEGORY) SUM(ID) > ROW_NUMBER() OVER (ORDER BY CATEGORY) SUM(ID)
> ------------------------------------- ------- > ------------------------------------- -------
> 1 12 > 1 12
...@@ -97,13 +97,13 @@ INSERT INTO TEST VALUES ...@@ -97,13 +97,13 @@ INSERT INTO TEST VALUES
(32, FALSE); (32, FALSE);
> update count: 6 > update count: 6
SELECT ROW_NUMBER() OVER (ORDER /**/ BY CATEGORY), SUM(ID) FROM TEST GROUP BY CATEGORY HAVING SUM(ID) = 12; SELECT ROW_NUMBER() OVER (ORDER BY CATEGORY), SUM(ID) FROM TEST GROUP BY CATEGORY HAVING SUM(ID) = 12;
> ROW_NUMBER() OVER (ORDER BY CATEGORY) SUM(ID) > ROW_NUMBER() OVER (ORDER BY CATEGORY) SUM(ID)
> ------------------------------------- ------- > ------------------------------------- -------
> 1 12 > 1 12
> rows: 1 > rows: 1
SELECT ROW_NUMBER() OVER (ORDER /**/ BY CATEGORY), SUM(ID) FROM TEST GROUP BY CATEGORY HAVING CATEGORY; SELECT ROW_NUMBER() OVER (ORDER BY CATEGORY), SUM(ID) FROM TEST GROUP BY CATEGORY HAVING CATEGORY;
> ROW_NUMBER() OVER (ORDER BY CATEGORY) SUM(ID) > ROW_NUMBER() OVER (ORDER BY CATEGORY) SUM(ID)
> ------------------------------------- ------- > ------------------------------------- -------
> 1 12 > 1 12
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论