Files
greptimedb/tests/cases/standalone/common/order/nulls_first_last.sql
dennis zhuang d8563ba56d feat: adds regex_extract function and more type tests (#7107)
* feat: adds format, regex_extract function and more type tests

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix: forgot functions

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* chore: forgot null type

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* test: forgot date type

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* feat: remove format function

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* test: update results after upgrading datafusion

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

---------

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2025-10-25 08:41:49 +00:00

47 lines
1.3 KiB
SQL

-- Migrated from DuckDB test: test/sql/order/test_nulls_first.test
-- Test NULLS FIRST/NULLS LAST
CREATE TABLE integers(i INTEGER, ts TIMESTAMP TIME INDEX);
INSERT INTO integers VALUES (1, 1000), (NULL, 2000);
-- Default NULL ordering (usually NULLS LAST in most systems)
SELECT i FROM integers ORDER BY i;
-- Explicit NULLS FIRST
SELECT i FROM integers ORDER BY i NULLS FIRST;
-- Explicit NULLS LAST
SELECT i FROM integers ORDER BY i NULLS LAST;
-- Multiple columns with mixed NULL handling
CREATE TABLE test(i INTEGER, j INTEGER, ts TIMESTAMP TIME INDEX);
INSERT INTO test VALUES (1, 1, 1000), (NULL, 1, 2000), (1, NULL, 3000);
SELECT i, j FROM test ORDER BY i NULLS FIRST, j NULLS LAST;
SELECT i, j FROM test ORDER BY i NULLS FIRST, j NULLS FIRST;
SELECT i, j FROM test ORDER BY i NULLS LAST, j NULLS FIRST;
-- Test with DESC ordering
SELECT i, j FROM test ORDER BY i DESC NULLS FIRST, j DESC NULLS LAST;
SELECT i, j FROM test ORDER BY i DESC NULLS LAST, j DESC NULLS FIRST;
-- Test with strings
CREATE TABLE strings(s VARCHAR, i INTEGER, ts TIMESTAMP TIME INDEX);
INSERT INTO strings VALUES ('apple', 1, 1000), (NULL, 2, 2000), ('banana', NULL, 3000);
SELECT s, i FROM strings ORDER BY s NULLS FIRST, i NULLS LAST;
SELECT s, i FROM strings ORDER BY s NULLS LAST, i NULLS FIRST;
DROP TABLE integers;
DROP TABLE test;
DROP TABLE strings;