sql icon indicating copy to clipboard operation
sql copied to clipboard

[Bug] Alias in ORDER BY expression throws semantic exception

Open dai-chen opened this issue 3 years ago • 0 comments

@jingyali-apr Thanks for confirming! I may have found where things go wrong: https://github.com/opensearch-project/sql/blob/907019cc8f7ce05c34ed453a75e4d897f55b57c5/sql/src/main/java/org/opensearch/sql/sql/parser/AstSortBuilder.java#L53

When we try to replace alias in ORDER BY, we only replace ordinal or alias directly. In our case, state is NOT NULL is an expression which causes alias replacement fail. Will debug to confirm and open issue/PR to fix. However, just to let you know, the fix would be only available in latest OpenSearch version (probably 2.3 next). Thanks!

Originally posted by @dai-chen in https://github.com/opensearch-project/sql/issues/292#issuecomment-1234612543

dai-chen avatar Sep 01 '22 23:09 dai-chen