-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2707a44
Add checks for Grouping functions restriction to be placed inside GRO…
astefan 51b19ef
Fixed bug where GROUP BY HISTOGRAM (not using alias) wasn't recognized
astefan f1f7397
Merge branch 'master' of https://github.com/elastic/elasticsearch int…
astefan 08f75e5
Merge branch 'master' of https://github.com/elastic/elasticsearch int…
astefan 2658b70
Address comments
astefan 36244c7
Merge branch 'master' of https://github.com/elastic/elasticsearch int…
astefan ff39950
Merge branch 'master' of https://github.com/elastic/elasticsearch int…
astefan 08a2bf7
Changes after merging master
astefan 597eeaa
Address comment
astefan 0e1b6c4
Merge branch 'master' of https://github.com/elastic/elasticsearch int…
astefan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.Collections; | ||
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, Collections.singletonList(interval)); | ||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.