Environment
- ArcadeDB v26.4.1-SNAPSHOT (latest)
Reproduction
CREATE VERTEX TYPE Concept
CREATE PROPERTY Concept.id STRING
CREATE PROPERTY Concept.status STRING
INSERT INTO Concept SET id = 'c1', status = 'open'
INSERT INTO Concept SET id = 'c2', status = 'settled'
-- FAILS:
SELECT id, status FROM Concept
ORDER BY CASE WHEN status = 'open' THEN 0 ELSE 1 END
LIMIT 10
Error: Failed to build ORDER BY item: Cannot read field "suffix" because "baseExpr.identifier" is null
What works
CASE WHEN in SELECT works fine. Ordering by the alias also works:
-- OK:
SELECT id, status, CASE WHEN status = 'open' THEN 0 ELSE 1 END AS sort_key
FROM Concept ORDER BY sort_key LIMIT 10
Expected
Inline CASE expressions in ORDER BY should work the same as in other SQL databases.
Workaround
Move the CASE expression to SELECT with an alias, ORDER BY the alias.
Environment
Reproduction
Error:
Failed to build ORDER BY item: Cannot read field "suffix" because "baseExpr.identifier" is nullWhat works
CASE WHEN in SELECT works fine. Ordering by the alias also works:
Expected
Inline CASE expressions in ORDER BY should work the same as in other SQL databases.
Workaround
Move the CASE expression to SELECT with an alias, ORDER BY the alias.