-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
SQL: Generate relevant error message when grouping functions are not used in GROUP BY #38017
Changes from 8 commits
2707a44
51b19ef
f1f7397
08f75e5
2658b70
36244c7
ff39950
08a2bf7
597eeaa
0e1b6c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,12 +10,14 @@ | |
import org.elasticsearch.xpack.sql.expression.Expressions; | ||
import org.elasticsearch.xpack.sql.expression.Expressions.ParamOrdinal; | ||
import org.elasticsearch.xpack.sql.expression.Literal; | ||
import org.elasticsearch.xpack.sql.tree.Source; | ||
import org.elasticsearch.xpack.sql.tree.NodeInfo; | ||
import org.elasticsearch.xpack.sql.tree.Source; | ||
import org.elasticsearch.xpack.sql.type.DataType; | ||
import org.elasticsearch.xpack.sql.type.DataTypes; | ||
|
||
import java.time.ZoneId; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public class Histogram extends GroupingFunction { | ||
|
@@ -24,8 +26,8 @@ public class Histogram extends GroupingFunction { | |
private final ZoneId zoneId; | ||
|
||
public Histogram(Source source, Expression field, Expression interval, ZoneId zoneId) { | ||
super(source, field); | ||
this.interval = (Literal) interval; | ||
super(source, field, Arrays.asList(interval)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not have this passed through parameters instead of extraChildren? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor improvement, use: |
||
this.interval = Literal.of(interval); | ||
this.zoneId = zoneId; | ||
} | ||
|
||
|
@@ -51,10 +53,13 @@ protected TypeResolution resolveType() { | |
|
||
return resolution; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Really minor: remove the whitespaces. |
||
@Override | ||
protected GroupingFunction replaceChild(Expression newChild) { | ||
return new Histogram(source(), newChild, interval, zoneId); | ||
public final GroupingFunction replaceChildren(List<Expression> newChildren) { | ||
if (newChildren.size() != 2) { | ||
throw new IllegalArgumentException("expected [2] children but received [" + newChildren.size() + "]"); | ||
} | ||
return new Histogram(source(), newChildren.get(0), newChildren.get(1), zoneId); | ||
} | ||
|
||
@Override | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this block is a bit condensed and could use some whitespace and indentation to make it more readable.
For example put
localFailures
on a new line.