mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-24 00:40:40 +00:00
95 lines
2.8 KiB
Plaintext
95 lines
2.8 KiB
Plaintext
CREATE TABLE test(i INTEGER, j INTEGER, t BIGINT TIME INDEX);
|
|
|
|
Affected Rows: 0
|
|
|
|
INSERT INTO test VALUES (1, 1, 1), (NULL, 1, 2), (1, NULL, 3);
|
|
|
|
Affected Rows: 3
|
|
|
|
SELECT * FROM test ORDER BY i NULLS FIRST, j NULLS LAST;
|
|
|
|
+---+---+---+
|
|
| i | j | t |
|
|
+---+---+---+
|
|
| | 1 | 2 |
|
|
| 1 | 1 | 1 |
|
|
| 1 | | 3 |
|
|
+---+---+---+
|
|
|
|
SELECT * FROM test ORDER BY i NULLS FIRST, j NULLS FIRST;
|
|
|
|
+---+---+---+
|
|
| i | j | t |
|
|
+---+---+---+
|
|
| | 1 | 2 |
|
|
| 1 | | 3 |
|
|
| 1 | 1 | 1 |
|
|
+---+---+---+
|
|
|
|
SELECT * FROM test ORDER BY i NULLS LAST, j NULLS FIRST;
|
|
|
|
+---+---+---+
|
|
| i | j | t |
|
|
+---+---+---+
|
|
| 1 | | 3 |
|
|
| 1 | 1 | 1 |
|
|
| | 1 | 2 |
|
|
+---+---+---+
|
|
|
|
-- TODO(ruihang): The following two SQL will fail under distributed mode with error
|
|
-- Error: 1003(Internal), status: Internal, message: "Failed to collect recordbatch, source: Failed to poll stream, source: Arrow error: Invalid argument error: batches[0] schema is different with argument schema.\n batches[0] schema: Schema { fields: [Field { name: \"i\", data_type: Int32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: \"j\", data_type: Int32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: \"t\", data_type: Int64, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {\"greptime:time_index\": \"true\"} }], metadata: {\"greptime:version\": \"0\"} },\n argument schema: Schema { fields: [Field { name: \"i\", data_type: Int32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: \"j\", data_type: Int32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: \"t\", data_type: Int64, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {\"greptime:time_index\": \"true\"} }], metadata: {} }\n ", details: [], metadata: MetadataMap { headers: {"inner_error_code": "Internal"} }
|
|
-- SELECT i, j, row_number() OVER (PARTITION BY i ORDER BY j NULLS FIRST) FROM test ORDER BY i NULLS FIRST, j NULLS FIRST;
|
|
-- SELECT i, j, row_number() OVER (PARTITION BY i ORDER BY j NULLS LAST) FROM test ORDER BY i NULLS FIRST, j NULLS FIRST;
|
|
SELECT * FROM test ORDER BY i NULLS FIRST, j NULLS LAST LIMIT 2;
|
|
|
|
+---+---+---+
|
|
| i | j | t |
|
|
+---+---+---+
|
|
| | 1 | 2 |
|
|
| 1 | 1 | 1 |
|
|
+---+---+---+
|
|
|
|
SELECT * FROM test ORDER BY i NULLS LAST, j NULLS LAST LIMIT 2;
|
|
|
|
+---+---+---+
|
|
| i | j | t |
|
|
+---+---+---+
|
|
| 1 | 1 | 1 |
|
|
| 1 | | 3 |
|
|
+---+---+---+
|
|
|
|
SELECT * FROM test ORDER BY i;
|
|
|
|
+---+---+---+
|
|
| i | j | t |
|
|
+---+---+---+
|
|
| 1 | 1 | 1 |
|
|
| 1 | | 3 |
|
|
| | 1 | 2 |
|
|
+---+---+---+
|
|
|
|
SELECT * FROM test ORDER BY i NULLS FIRST;
|
|
|
|
+---+---+---+
|
|
| i | j | t |
|
|
+---+---+---+
|
|
| | 1 | 2 |
|
|
| 1 | 1 | 1 |
|
|
| 1 | | 3 |
|
|
+---+---+---+
|
|
|
|
SELECT * FROM test ORDER BY i NULLS LAST;
|
|
|
|
+---+---+---+
|
|
| i | j | t |
|
|
+---+---+---+
|
|
| 1 | 1 | 1 |
|
|
| 1 | | 3 |
|
|
| | 1 | 2 |
|
|
+---+---+---+
|
|
|
|
DROP TABLE test;
|
|
|
|
Affected Rows: 1
|
|
|