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

Group By does not support complex expression #262

Open
xlxie opened this issue Oct 7, 2021 · 2 comments
Open

Group By does not support complex expression #262

xlxie opened this issue Oct 7, 2021 · 2 comments

Comments

@xlxie
Copy link

xlxie commented Oct 7, 2021

Summary of Bug

The group by operation does not support complex expression as the group by key. For example, group by (case when column1 is null)...

Version

Reproducible on all versions.

Steps to Reproduce

select case when column1 is null then 'null_value' else column end, max(column2) group by case when column1 is null then 'null_value' else column1 end

Reasons

I tried to find out the behind reason. An exception was thrown at Utils.scala:1464. The serializer treefold the CASE WHEN expression and tried to look for column1 in the output list of the sub-executor and it failed.

Finally, I found the root cause is at strategies.scala:177-234. When the optimizer generates the plan for encrypted SQL, it generates multiple executors for one AGG executor. And it simply passes the group by key of the original AGG executor to other nodes. As such, for some of the generated executors, the serializer failed to find the input of the executors from the sub-executor's output.

@octaviansima
Copy link
Collaborator

@xlxie I just took a look, and it does seem that our aggregates do not support complex expressions as group keys for that exact reason. Would you be interested in submitting a PR with the fix? Happy to help debug, offer advice, and review!

@xlxie
Copy link
Author

xlxie commented Oct 13, 2021

No problem. Please allow me to spend some time to learn about how to contribute to this project.

@octaviansima octaviansima assigned xlxie and unassigned octaviansima Oct 13, 2021
xlxie pushed a commit to xlxie/opaque-sql that referenced this issue Oct 22, 2021
xlxie pushed a commit to xlxie/opaque-sql that referenced this issue Oct 22, 2021
xlxie pushed a commit to xlxie/opaque-sql that referenced this issue Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants