Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Alias in ORDER BY expression throws semantic exception #798

Open
dai-chen opened this issue Sep 1, 2022 · 1 comment
Open

[Bug] Alias in ORDER BY expression throws semantic exception #798

dai-chen opened this issue Sep 1, 2022 · 1 comment
Labels
bug Something isn't working SQL

Comments

@dai-chen
Copy link
Collaborator

dai-chen commented Sep 1, 2022

@jingyali-apr Thanks for confirming! I may have found where things go wrong:

querySpec.replaceIfAliasOrOrdinal(items.get(i)),

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 #292 (comment)

@dai-chen dai-chen added bug Something isn't working SQL labels Sep 1, 2022
@dai-chen
Copy link
Collaborator Author

dai-chen commented Sep 7, 2022

I checked the code. It's easy to quick fix field IS (NOT) NULL in AstSortBuilder. However, to support general case for arbitrary expression, it requires cloning entire expression after the alias replacement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working SQL
Projects
None yet
Development

No branches or pull requests

1 participant