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

"having field = value" in select statement can't work correctly #33

Open
nivalsoul opened this issue Mar 23, 2017 · 2 comments
Open

"having field = value" in select statement can't work correctly #33

nivalsoul opened this issue Mar 23, 2017 · 2 comments

Comments

@nivalsoul
Copy link

nivalsoul commented Mar 23, 2017

if I have the sql like: select name, count(1) as num from table group by name having num = 5
the "num = 5" can not work correctly because of this use 【==】comparison operation on two Double type values, the code is in the following file:
sql4es/src/main/java/nl/anchormen/sql4es/model/expression/SimpleComparison.java

if(this.comparisonType == Type.EQUAL) return leftValue == rightValue;
if(this.comparisonType == Type.GREATER_THAN) return leftValue > rightValue;
if(this.comparisonType == Type.GREATER_THAN_OR_EQUAL) return leftValue >= rightValue;
if(this.comparisonType == Type.LESS_THAN) return leftValue < rightValue;
if(this.comparisonType == Type.LESS_THAN_OR_EQUAL) return leftValue <= rightValue;

if this can use: return leftValue.equals(rightValue); ?

@corneversloot
Copy link
Member

You are right that this poses a problem and I think your fix is suffice. I will see if I can update it soon.

ps would be better to implement the HAVING as a pipeline aggregation and let ES handle it but that would be future work.

corneversloot added a commit that referenced this issue Mar 26, 2017
@corneversloot
Copy link
Member

I have added the proposed fix which is released in version 0.9.2.4. Please test if this version works for you as it should

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants