From 3fe5b42b963c4e0250f18ce87e485a8d4668507a Mon Sep 17 00:00:00 2001 From: Arun Sharma Date: Tue, 29 Sep 2026 09:56:45 -0700 Subject: [PATCH] test: regression test for LadybugDB/ladybug#1067 ORDER BY STRING then numeric Merging sorted key blocks ignored trailing keys once all STRING keys tied, misordering the second key (deterministic with multiple key blocks, e.g. 20k rows). --- test/test_issue.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/test_issue.py b/test/test_issue.py index 0faf62a..54bb41a 100644 --- a/test/test_issue.py +++ b/test/test_issue.py @@ -10,6 +10,27 @@ # required by python-lint +def test_issue_1067_order_by_string_then_numeric(conn_db_readwrite: ConnDB) -> None: + # https://github.com/LadybugDB/ladybug/issues/1067 + # KeyBlockMerger::compareTuplePtrWithStringCol ignored trailing keys once all + # STRING keys tied, misordering e.g. ORDER BY , when merging + # sorted key blocks (deterministic once the sort spills to multiple key blocks). + conn, _ = conn_db_readwrite + conn.execute( + "CREATE NODE TABLE Obs(id INT64, name STRING, value DOUBLE, PRIMARY KEY(id))" + ) + conn.execute( + "COPY Obs FROM (UNWIND range(0, 19999) AS o RETURN o, " + "'item' + CAST(o % 3 AS STRING), CAST((o * 7919) % 100003 AS DOUBLE))" + ) + result = conn.execute( + "MATCH (o:Obs) RETURN o.name, o.value ORDER BY o.name, o.value" + ) + rows = result.get_all() + result.close() + assert rows == sorted(rows) + + def test_param_empty(conn_db_readwrite: ConnDB) -> None: conn, _ = conn_db_readwrite lst = [[]]