Checkstyle and license headers in plugin

Original commit: elastic/x-pack-elasticsearch@e7855b949f
This commit is contained in:
Nik Everett 2017-06-22 12:22:57 -04:00
parent b504b0d2d9
commit 933a51edef
25 changed files with 1346 additions and 1495 deletions

View File

@ -40,7 +40,7 @@ subprojects {
}
tasks.withType(LicenseHeadersTask.class) {
approvedLicenses = ['Elasticsearch Confidential']
approvedLicenses = ['Elasticsearch Confidential', 'Generated']
additionalLicense 'ESCON', 'Elasticsearch Confidential', 'ELASTICSEARCH CONFIDENTIAL'
}
ext.projectSubstitutions += [ "org.elasticsearch.plugin:x-pack-api:${version}": ':x-pack-elasticsearch:plugin']

View File

@ -10,6 +10,7 @@
<!-- NOCOMMIT Temporary-->
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]sql[/\\].*.java" checks="LineLength" />
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]sql[/\\]expression[/\\].*.java" checks="EqualsHashCode" />
<suppress files="sql-clients[/\\].*.java" checks="LineLength" />
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]common[/\\]action[/\\]XPackDeleteByQueryAction.java" checks="LineLength" />

View File

@ -969,7 +969,7 @@ public class Analyzer extends RuleExecutor<LogicalPlan> {
}
}
static abstract class AnalyzeRule<SubPlan extends LogicalPlan> extends Rule<SubPlan, LogicalPlan> {
abstract static class AnalyzeRule<SubPlan extends LogicalPlan> extends Rule<SubPlan, LogicalPlan> {
// transformUp (post-order) - that is first children and then the node
// but with a twist; only if the tree is not resolved or analyzed

View File

@ -5,8 +5,6 @@
*/
package org.elasticsearch.xpack.sql.analysis.analyzer;
import java.util.*;
import org.elasticsearch.xpack.sql.expression.Attribute;
import org.elasticsearch.xpack.sql.expression.AttributeSet;
import org.elasticsearch.xpack.sql.expression.Expressions;
@ -20,6 +18,14 @@ import org.elasticsearch.xpack.sql.plan.logical.LogicalPlan;
import org.elasticsearch.xpack.sql.plan.logical.Project;
import org.elasticsearch.xpack.sql.tree.Node;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Set;
import static java.lang.String.format;
import static java.util.stream.Collectors.toList;
@ -29,7 +35,7 @@ abstract class Verifier {
private final Node<?> source;
private final String message;
public Failure(Node<?> source, String message) {
Failure(Node<?> source, String message) {
this.source = source;
this.message = message;
}

View File

@ -11,7 +11,7 @@ import org.elasticsearch.search.SearchHitField;
class DocValueExtractor implements HitExtractor {
private final String fieldName;
public DocValueExtractor(String name) {
DocValueExtractor(String name) {
this.fieldName = name;
}

View File

@ -17,7 +17,7 @@ class InnerHitExtractor implements HitExtractor {
private final boolean useDocValue;
private final String[] tree;
public InnerHitExtractor(String hitName, String name, boolean useDocValue) {
InnerHitExtractor(String hitName, String name, boolean useDocValue) {
this.hitName = hitName;
this.fieldName = name;
this.useDocValue = useDocValue;

View File

@ -87,11 +87,11 @@ public class Scroller {
ScrollerActionListener l = new SessionScrollActionListener(listener, previous.client, previous.keepAlive, previous.schema, ext, previous.limit, previous.docsRead);
previous.client.searchScroll(new SearchScrollRequest(scrollId).scroll(previous.keepAlive), l);
}
}
// dedicated scroll used for aggs-only/group-by results
class AggsScrollActionListener extends ScrollerActionListener {
/**
* Dedicated scroll used for aggs-only/group-by results.
*/
static class AggsScrollActionListener extends ScrollerActionListener {
private final QueryContainer query;
AggsScrollActionListener(ActionListener<RowSetCursor> listener, Client client, TimeValue keepAlive, Schema schema, QueryContainer query) {
@ -176,9 +176,10 @@ class AggsScrollActionListener extends ScrollerActionListener {
}
}
// initial scroll used for parsing search hits (handles possible aggs)
class HandshakeScrollActionListener extends SearchHitsActionListener {
/**
* Initial scroll used for parsing search hits (handles possible aggs).
*/
static class HandshakeScrollActionListener extends SearchHitsActionListener {
private final QueryContainer query;
HandshakeScrollActionListener(ActionListener<RowSetCursor> listener, Client client, TimeValue keepAlive, Schema schema, QueryContainer query) {
@ -229,8 +230,10 @@ class HandshakeScrollActionListener extends SearchHitsActionListener {
}
}
// listener used for streaming the rest of the results after the handshake has been used
class SessionScrollActionListener extends SearchHitsActionListener {
/**
* Listener used for streaming the rest of the results after the handshake has been used.
*/
static class SessionScrollActionListener extends SearchHitsActionListener {
private List<HitExtractor> exts;
@ -245,12 +248,12 @@ class SessionScrollActionListener extends SearchHitsActionListener {
}
}
abstract class SearchHitsActionListener extends ScrollerActionListener {
abstract static class SearchHitsActionListener extends ScrollerActionListener {
final int limit;
int docsRead;
SearchHitsActionListener(ActionListener<RowSetCursor> listener, Client client, TimeValue keepAlive, Schema schema, int limit, int docsRead) {
SearchHitsActionListener(ActionListener<RowSetCursor> listener, Client client, TimeValue keepAlive, Schema schema, int limit,
int docsRead) {
super(listener, client, keepAlive, schema);
this.limit = limit;
this.docsRead = docsRead;
@ -277,8 +280,7 @@ abstract class SearchHitsActionListener extends ScrollerActionListener {
clearScroll(scrollId);
// and remove it to indicate no more data is expected
scrollId = null;
}
else {
} else {
next = l -> Scroller.from(l, this, response.getScrollId(), exts);
}
}
@ -305,7 +307,7 @@ abstract class SearchHitsActionListener extends ScrollerActionListener {
protected abstract List<HitExtractor> getExtractors();
}
abstract class ScrollerActionListener implements ActionListener<SearchResponse> {
abstract static class ScrollerActionListener implements ActionListener<SearchResponse> {
final ActionListener<RowSetCursor> listener;
@ -349,3 +351,4 @@ abstract class ScrollerActionListener implements ActionListener<SearchResponse>
listener.onFailure(ex);
}
}
}

View File

@ -12,7 +12,7 @@ import org.elasticsearch.search.SearchHit;
class SourceExtractor implements HitExtractor {
private final String fieldName;
public SourceExtractor(String name) {
SourceExtractor(String name) {
this.fieldName = name;
}

View File

@ -43,6 +43,7 @@ public abstract class NamedExpression extends Expression {
@Override
public final int hashCode() {
// NOCOMMIT making this final upsets checkstyle.
return id.hashCode();
}

View File

@ -14,7 +14,7 @@ import org.elasticsearch.xpack.sql.type.DataType;
abstract class UnresolvedNamedExpression extends NamedExpression implements Unresolvable {
public UnresolvedNamedExpression(Location location, List<Expression> children) {
UnresolvedNamedExpression(Location location, List<Expression> children) {
super(location, "<unresolved>", children, ExpressionIdGenerator.EMPTY);
}

View File

@ -5,16 +5,53 @@
*/
package org.elasticsearch.xpack.sql.expression.function;
import org.elasticsearch.xpack.sql.SqlException;
import org.elasticsearch.xpack.sql.expression.function.aggregate.Avg;
import org.elasticsearch.xpack.sql.expression.function.aggregate.Count;
import org.elasticsearch.xpack.sql.expression.function.aggregate.Max;
import org.elasticsearch.xpack.sql.expression.function.aggregate.Min;
import org.elasticsearch.xpack.sql.expression.function.aggregate.Sum;
import org.elasticsearch.xpack.sql.expression.function.scalar.ScalarFunction;
import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.DayOfMonth;
import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.DayOfWeek;
import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.DayOfYear;
import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.HourOfDay;
import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.MinuteOfDay;
import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.MinuteOfHour;
import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.MonthOfYear;
import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.SecondOfMinute;
import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.Year;
import org.elasticsearch.xpack.sql.expression.function.scalar.math.ACos;
import org.elasticsearch.xpack.sql.expression.function.scalar.math.ASin;
import org.elasticsearch.xpack.sql.expression.function.scalar.math.ATan;
import org.elasticsearch.xpack.sql.expression.function.scalar.math.Abs;
import org.elasticsearch.xpack.sql.expression.function.scalar.math.Cbrt;
import org.elasticsearch.xpack.sql.expression.function.scalar.math.Ceil;
import org.elasticsearch.xpack.sql.expression.function.scalar.math.Cos;
import org.elasticsearch.xpack.sql.expression.function.scalar.math.Cosh;
import org.elasticsearch.xpack.sql.expression.function.scalar.math.Degrees;
import org.elasticsearch.xpack.sql.expression.function.scalar.math.E;
import org.elasticsearch.xpack.sql.expression.function.scalar.math.Exp;
import org.elasticsearch.xpack.sql.expression.function.scalar.math.Expm1;
import org.elasticsearch.xpack.sql.expression.function.scalar.math.Floor;
import org.elasticsearch.xpack.sql.expression.function.scalar.math.Log;
import org.elasticsearch.xpack.sql.expression.function.scalar.math.Log10;
import org.elasticsearch.xpack.sql.expression.function.scalar.math.Pi;
import org.elasticsearch.xpack.sql.expression.function.scalar.math.Radians;
import org.elasticsearch.xpack.sql.expression.function.scalar.math.Round;
import org.elasticsearch.xpack.sql.expression.function.scalar.math.Sin;
import org.elasticsearch.xpack.sql.expression.function.scalar.math.Sinh;
import org.elasticsearch.xpack.sql.expression.function.scalar.math.Sqrt;
import org.elasticsearch.xpack.sql.expression.function.scalar.math.Tan;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.net.URL;
import java.util.*;
import org.elasticsearch.xpack.sql.SqlException;
import org.elasticsearch.xpack.sql.expression.function.aggregate.*;
import org.elasticsearch.xpack.sql.expression.function.scalar.ScalarFunction;
import org.elasticsearch.xpack.sql.expression.function.scalar.datetime.*;
import org.elasticsearch.xpack.sql.expression.function.scalar.math.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Map;
import static org.elasticsearch.xpack.sql.util.CollectionUtils.combine;
import static org.elasticsearch.xpack.sql.util.CollectionUtils.of;

View File

@ -16,7 +16,7 @@ public enum FunctionType {
private final Class<? extends Function> baseClass;
private FunctionType(Class<? extends Function> base) {
FunctionType(Class<? extends Function> base) {
this.baseClass = base;
}

View File

@ -16,7 +16,7 @@ import org.elasticsearch.xpack.sql.type.DataTypes;
public class FullTextPredicate extends Expression {
public static enum Operator {
public enum Operator {
AND,
OR;

View File

@ -5,20 +5,13 @@
*/
package org.elasticsearch.xpack.sql.optimizer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.elasticsearch.xpack.sql.SqlIllegalArgumentException;
import org.elasticsearch.xpack.sql.analysis.catalog.Catalog;
import org.elasticsearch.xpack.sql.expression.Alias;
import org.elasticsearch.xpack.sql.expression.Attribute;
import org.elasticsearch.xpack.sql.expression.AttributeSet;
import org.elasticsearch.xpack.sql.expression.BinaryExpression;
import org.elasticsearch.xpack.sql.expression.BinaryExpression.Negateable;
import org.elasticsearch.xpack.sql.expression.Expression;
import org.elasticsearch.xpack.sql.expression.ExpressionSet;
import org.elasticsearch.xpack.sql.expression.Expressions;
@ -26,7 +19,6 @@ import org.elasticsearch.xpack.sql.expression.Literal;
import org.elasticsearch.xpack.sql.expression.NamedExpression;
import org.elasticsearch.xpack.sql.expression.NestedFieldAttribute;
import org.elasticsearch.xpack.sql.expression.Order;
import org.elasticsearch.xpack.sql.expression.BinaryExpression.Negateable;
import org.elasticsearch.xpack.sql.expression.function.Function;
import org.elasticsearch.xpack.sql.expression.function.aggregate.AggregateFunctionAttribute;
import org.elasticsearch.xpack.sql.expression.function.scalar.Cast;
@ -53,11 +45,23 @@ import org.elasticsearch.xpack.sql.rule.RuleExecutor;
import org.elasticsearch.xpack.sql.session.EmptyExecutable;
import org.elasticsearch.xpack.sql.util.CollectionUtils;
import static java.util.stream.Collectors.toList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import static java.util.stream.Collectors.toList;
import static org.elasticsearch.xpack.sql.expression.Literal.FALSE;
import static org.elasticsearch.xpack.sql.expression.Literal.TRUE;
import static org.elasticsearch.xpack.sql.expression.predicate.Predicates.*;
import static org.elasticsearch.xpack.sql.expression.predicate.Predicates.combineAnd;
import static org.elasticsearch.xpack.sql.expression.predicate.Predicates.combineOr;
import static org.elasticsearch.xpack.sql.expression.predicate.Predicates.inCommon;
import static org.elasticsearch.xpack.sql.expression.predicate.Predicates.splitAnd;
import static org.elasticsearch.xpack.sql.expression.predicate.Predicates.splitOr;
import static org.elasticsearch.xpack.sql.expression.predicate.Predicates.subtract;
public class Optimizer extends RuleExecutor<LogicalPlan> {
@ -108,10 +112,7 @@ public class Optimizer extends RuleExecutor<LogicalPlan> {
return Arrays.asList(resolution, aggregate, cleanup, label);
}
}
class PruneSubqueryAliases extends OptimizerRule<SubQueryAlias> {
static class PruneSubqueryAliases extends OptimizerRule<SubQueryAlias> {
PruneSubqueryAliases() {
super(false);
@ -123,7 +124,7 @@ class PruneSubqueryAliases extends OptimizerRule<SubQueryAlias> {
}
}
class CleanAliases extends OptimizerRule<LogicalPlan> {
static class CleanAliases extends OptimizerRule<LogicalPlan> {
CleanAliases() {
super(false);
@ -173,7 +174,7 @@ class CleanAliases extends OptimizerRule<LogicalPlan> {
}
}
class PruneDuplicatesInGroupBy extends OptimizerRule<Aggregate> {
static class PruneDuplicatesInGroupBy extends OptimizerRule<Aggregate> {
@Override
protected LogicalPlan rule(Aggregate agg) {
@ -189,7 +190,7 @@ class PruneDuplicatesInGroupBy extends OptimizerRule<Aggregate> {
}
}
class ReplaceDuplicateAggsWithReferences extends OptimizerRule<Aggregate> {
static class ReplaceDuplicateAggsWithReferences extends OptimizerRule<Aggregate> {
@Override
protected LogicalPlan rule(Aggregate agg) {
@ -223,7 +224,7 @@ class ReplaceDuplicateAggsWithReferences extends OptimizerRule<Aggregate> {
}
}
class PruneFilters extends OptimizerRule<Filter> {
static class PruneFilters extends OptimizerRule<Filter> {
@Override
protected LogicalPlan rule(Filter filter) {
@ -241,7 +242,7 @@ class PruneFilters extends OptimizerRule<Filter> {
}
}
class ReplaceAliasesInHaving extends OptimizerRule<Filter> {
static class ReplaceAliasesInHaving extends OptimizerRule<Filter> {
@Override
protected LogicalPlan rule(Filter filter) {
@ -261,7 +262,7 @@ class ReplaceAliasesInHaving extends OptimizerRule<Filter> {
}
}
class ProjectPruning extends OptimizerRule<Project> {
static class ProjectPruning extends OptimizerRule<Project> {
@Override
protected LogicalPlan rule(Project project) {
@ -280,7 +281,7 @@ class ProjectPruning extends OptimizerRule<Project> {
}
}
class PruneOrderByNestedFields extends OptimizerRule<Project> {
static class PruneOrderByNestedFields extends OptimizerRule<Project> {
@Override
protected LogicalPlan rule(Project project) {
@ -348,7 +349,7 @@ class PruneOrderByNestedFields extends OptimizerRule<Project> {
}
}
class PruneOrderBy extends OptimizerRule<OrderBy> {
static class PruneOrderBy extends OptimizerRule<OrderBy> {
@Override
protected LogicalPlan rule(OrderBy ob) {
@ -386,7 +387,7 @@ class PruneOrderBy extends OptimizerRule<OrderBy> {
}
}
class CombineLimits extends OptimizerRule<Limit> {
static class CombineLimits extends OptimizerRule<Limit> {
@Override
protected LogicalPlan rule(Limit limit) {
@ -398,7 +399,7 @@ class CombineLimits extends OptimizerRule<Limit> {
}
// NB: it is important to start replacing casts from the bottom to properly replace aliases
class PruneCast extends Rule<LogicalPlan, LogicalPlan> {
static class PruneCast extends Rule<LogicalPlan, LogicalPlan> {
@Override
public LogicalPlan apply(LogicalPlan plan) {
@ -471,8 +472,7 @@ class PruneCast extends Rule<LogicalPlan, LogicalPlan> {
}
}
class PruneDuplicateFunctions extends Rule<LogicalPlan, LogicalPlan> {
static class PruneDuplicateFunctions extends Rule<LogicalPlan, LogicalPlan> {
@Override
public LogicalPlan apply(LogicalPlan p) {
@ -506,7 +506,7 @@ class PruneDuplicateFunctions extends Rule<LogicalPlan, LogicalPlan> {
}
}
class SkipQueryOnLimitZero extends OptimizerRule<Limit> {
static class SkipQueryOnLimitZero extends OptimizerRule<Limit> {
@Override
protected LogicalPlan rule(Limit limit) {
@ -519,7 +519,7 @@ class SkipQueryOnLimitZero extends OptimizerRule<Limit> {
}
}
class CombineFilters extends OptimizerRule<Filter> {
static class CombineFilters extends OptimizerRule<Filter> {
@Override
protected LogicalPlan rule(Filter filter) {
@ -531,7 +531,7 @@ class CombineFilters extends OptimizerRule<Filter> {
}
}
class BooleanSimplification extends OptimizerExpressionUpRule {
static class BooleanSimplification extends OptimizerExpressionUpRule {
@Override
protected Expression rule(Expression e) {
@ -630,7 +630,7 @@ class BooleanSimplification extends OptimizerExpressionUpRule {
}
}
class BinaryComparisonSimplification extends OptimizerExpressionUpRule {
static class BinaryComparisonSimplification extends OptimizerExpressionUpRule {
@Override
protected Expression rule(Expression e) {
@ -659,7 +659,7 @@ class BinaryComparisonSimplification extends OptimizerExpressionUpRule {
}
}
class BooleanLiteralsOnTheRight extends OptimizerExpressionUpRule {
static class BooleanLiteralsOnTheRight extends OptimizerExpressionUpRule {
@Override
protected Expression rule(Expression e) {
@ -671,7 +671,7 @@ class BooleanLiteralsOnTheRight extends OptimizerExpressionUpRule {
}
}
class CombineComparisonsIntoRange extends OptimizerExpressionUpRule {
static class CombineComparisonsIntoRange extends OptimizerExpressionUpRule {
@Override
protected Expression rule(Expression e) {
@ -705,7 +705,7 @@ class CombineComparisonsIntoRange extends OptimizerExpressionUpRule {
}
class SetAsOptimized extends Rule<LogicalPlan, LogicalPlan> {
static class SetAsOptimized extends Rule<LogicalPlan, LogicalPlan> {
@Override
public LogicalPlan apply(LogicalPlan plan) {
@ -723,7 +723,7 @@ class SetAsOptimized extends Rule<LogicalPlan, LogicalPlan> {
}
abstract class OptimizerRule<SubPlan extends LogicalPlan> extends Rule<SubPlan, LogicalPlan> {
abstract static class OptimizerRule<SubPlan extends LogicalPlan> extends Rule<SubPlan, LogicalPlan> {
private final boolean transformDown;
@ -745,7 +745,7 @@ abstract class OptimizerRule<SubPlan extends LogicalPlan> extends Rule<SubPlan,
protected abstract LogicalPlan rule(SubPlan plan);
}
abstract class OptimizerExpressionUpRule extends Rule<LogicalPlan, LogicalPlan> {
abstract static class OptimizerExpressionUpRule extends Rule<LogicalPlan, LogicalPlan> {
private final boolean transformDown;
@ -771,3 +771,4 @@ abstract class OptimizerExpressionUpRule extends Rule<LogicalPlan, LogicalPlan>
protected abstract Expression rule(Expression e);
}
}

View File

@ -13,9 +13,10 @@ import org.antlr.v4.runtime.IntStream;
// extension of ANTLR that does the uppercasing once for the whole stream
// the ugly part is that it has to duplicate LA method
class CaseInsensitiveStream extends ANTLRInputStream {
// NOCOMMIT maybe we can fix this in the lexer or on the way in so we don't need the LA override
protected char[] uppedChars;
public CaseInsensitiveStream(String input) {
CaseInsensitiveStream(String input) {
super(input);
this.uppedChars = input.toUpperCase(Locale.ROOT).toCharArray();
}

View File

@ -1,204 +0,0 @@
T__0=1
T__1=2
T__2=3
T__3=4
T__4=5
SELECT=6
FROM=7
AS=8
ALL=9
WHEN=10
THEN=11
ANY=12
DISTINCT=13
WHERE=14
GROUP=15
BY=16
GROUPING=17
SETS=18
ORDER=19
HAVING=20
LIMIT=21
OR=22
AND=23
IN=24
NOT=25
NO=26
EXISTS=27
BETWEEN=28
LIKE=29
RLIKE=30
IS=31
NULL=32
TRUE=33
FALSE=34
LAST=35
ASC=36
DESC=37
FOR=38
INTEGER=39
JOIN=40
CROSS=41
OUTER=42
INNER=43
LEFT=44
RIGHT=45
FULL=46
NATURAL=47
USING=48
ON=49
WITH=50
TABLE=51
INTO=52
DESCRIBE=53
OPTION=54
EXPLAIN=55
ANALYZE=56
FORMAT=57
TYPE=58
TEXT=59
VERIFY=60
GRAPHVIZ=61
LOGICAL=62
PHYSICAL=63
SHOW=64
TABLES=65
COLUMNS=66
COLUMN=67
FUNCTIONS=68
TO=69
DEBUG=70
PLAN=71
PARSED=72
ANALYZED=73
OPTIMIZED=74
MAPPED=75
EXECUTABLE=76
USE=77
SET=78
RESET=79
SESSION=80
SCHEMAS=81
EXTRACT=82
QUERY=83
MATCH=84
CAST=85
EQ=86
NEQ=87
LT=88
LTE=89
GT=90
GTE=91
PLUS=92
MINUS=93
ASTERISK=94
SLASH=95
PERCENT=96
CONCAT=97
STRING=98
INTEGER_VALUE=99
DECIMAL_VALUE=100
IDENTIFIER=101
DIGIT_IDENTIFIER=102
QUOTED_IDENTIFIER=103
BACKQUOTED_IDENTIFIER=104
SIMPLE_COMMENT=105
BRACKETED_COMMENT=106
WS=107
UNRECOGNIZED=108
'('=1
')'=2
','=3
'.'=4
'"'=5
'SELECT'=6
'FROM'=7
'AS'=8
'ALL'=9
'WHEN'=10
'THEN'=11
'ANY'=12
'DISTINCT'=13
'WHERE'=14
'GROUP'=15
'BY'=16
'GROUPING'=17
'SETS'=18
'ORDER'=19
'HAVING'=20
'LIMIT'=21
'OR'=22
'AND'=23
'IN'=24
'NOT'=25
'NO'=26
'EXISTS'=27
'BETWEEN'=28
'LIKE'=29
'RLIKE'=30
'IS'=31
'NULL'=32
'TRUE'=33
'FALSE'=34
'LAST'=35
'ASC'=36
'DESC'=37
'FOR'=38
'INTEGER'=39
'JOIN'=40
'CROSS'=41
'OUTER'=42
'INNER'=43
'LEFT'=44
'RIGHT'=45
'FULL'=46
'NATURAL'=47
'USING'=48
'ON'=49
'WITH'=50
'TABLE'=51
'INTO'=52
'DESCRIBE'=53
'OPTION'=54
'EXPLAIN'=55
'ANALYZE'=56
'FORMAT'=57
'TYPE'=58
'TEXT'=59
'VERIFY'=60
'GRAPHVIZ'=61
'LOGICAL'=62
'PHYSICAL'=63
'SHOW'=64
'TABLES'=65
'COLUMNS'=66
'COLUMN'=67
'FUNCTIONS'=68
'TO'=69
'DEBUG'=70
'PLAN'=71
'PARSED'=72
'ANALYZED'=73
'OPTIMIZED'=74
'MAPPED'=75
'EXECUTABLE'=76
'USE'=77
'SET'=78
'RESET'=79
'SESSION'=80
'SCHEMAS'=81
'EXTRACT'=82
'QUERY'=83
'MATCH'=84
'CAST'=85
'='=86
'<'=88
'<='=89
'>'=90
'>='=91
'+'=92
'-'=93
'*'=94
'/'=95
'%'=96
'||'=97

View File

@ -42,4 +42,10 @@ abstract class BinaryPlan extends LogicalPlan {
return Objects.equals(left(), other.left())
&& Objects.equals(right(), other.right());
}
@Override
public int hashCode() {
return Objects.hash(left, right);
}
}

View File

@ -22,11 +22,12 @@ public class Join extends BinaryPlan {
private final JoinType type;
private final Expression condition;
public static enum JoinType {
INNER, LEFT // OUTER
, RIGHT // OUTER
, FULL // OUTER
, IMPLICIT
public enum JoinType {
INNER,
LEFT, // OUTER
RIGHT, // OUTER
FULL, // OUTER
IMPLICIT,
}
public Join(Location location, LogicalPlan left, LogicalPlan right, JoinType type, Expression condition) {

View File

@ -10,8 +10,7 @@ import java.util.Collections;
import org.elasticsearch.xpack.sql.tree.Location;
abstract class LeafExec extends PhysicalPlan {
public LeafExec(Location location) {
LeafExec(Location location) {
super(location, Collections.emptyList());
}
}

View File

@ -124,9 +124,8 @@ class Mapper extends RuleExecutor<PhysicalPlan> {
throw new UnsupportedOperationException("Don't know how to handle join " + join.nodeString());
}
}
}
abstract class MapExecRule<SubPlan extends LogicalPlan> extends Rule<UnplannedExec, PhysicalPlan> {
abstract static class MapExecRule<SubPlan extends LogicalPlan> extends Rule<UnplannedExec, PhysicalPlan> {
private final Class<SubPlan> subPlanToken = ReflectionUtils.detectSuperTypeForRuleLike(getClass());
@ -147,3 +146,4 @@ abstract class MapExecRule<SubPlan extends LogicalPlan> extends Rule<UnplannedEx
protected abstract PhysicalPlan map(SubPlan plan);
}
}

View File

@ -470,10 +470,11 @@ class QueryFolder extends RuleExecutor<PhysicalPlan> {
return exec.with(qContainer);
}
}
}
// rule for folding physical plans together
abstract class FoldingRule<SubPlan extends PhysicalPlan> extends Rule<SubPlan, PhysicalPlan> {
/**
* Rule for folding physical plans together.
*/
abstract static class FoldingRule<SubPlan extends PhysicalPlan> extends Rule<SubPlan, PhysicalPlan> {
@Override
public final PhysicalPlan apply(PhysicalPlan plan) {
@ -483,3 +484,5 @@ abstract class FoldingRule<SubPlan extends PhysicalPlan> extends Rule<SubPlan, P
@Override
protected abstract PhysicalPlan rule(SubPlan plan);
}
}

View File

@ -5,14 +5,6 @@
*/
package org.elasticsearch.xpack.sql.planner;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import org.elasticsearch.xpack.sql.SqlIllegalArgumentException;
import org.elasticsearch.xpack.sql.expression.Attribute;
import org.elasticsearch.xpack.sql.expression.BinaryExpression;
@ -51,7 +43,6 @@ import org.elasticsearch.xpack.sql.expression.predicate.fulltext.MultiMatchQuery
import org.elasticsearch.xpack.sql.expression.predicate.fulltext.StringQueryPredicate;
import org.elasticsearch.xpack.sql.expression.regex.Like;
import org.elasticsearch.xpack.sql.expression.regex.RLike;
import org.elasticsearch.xpack.sql.planner.QueryTranslator.QueryTranslation;
import org.elasticsearch.xpack.sql.querydsl.agg.Agg;
import org.elasticsearch.xpack.sql.querydsl.agg.AggFilter;
import org.elasticsearch.xpack.sql.querydsl.agg.AndAggFilter;
@ -83,12 +74,18 @@ import org.elasticsearch.xpack.sql.type.DataTypes;
import org.elasticsearch.xpack.sql.util.Assert;
import org.elasticsearch.xpack.sql.util.ReflectionUtils;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import static java.lang.String.format;
import static java.util.stream.Collectors.toList;
import static org.elasticsearch.xpack.sql.expression.function.scalar.script.ParamsBuilder.paramsBuilder;
import static org.elasticsearch.xpack.sql.expression.function.scalar.script.ScriptTemplate.formatTemplate;
import static org.elasticsearch.xpack.sql.planner.QueryTranslator.*;
abstract class QueryTranslator {
@ -399,12 +396,10 @@ abstract class QueryTranslator {
}
throw new SqlIllegalArgumentException("Does not know how to convert argument %s for functon %s", arg.nodeString(), af.nodeString());
}
}
// TODO: need to optimize on ngram
// TODO: see whether escaping is needed
class Likes extends ExppressionTranslator<BinaryExpression> {
static class Likes extends ExppressionTranslator<BinaryExpression> {
@Override
protected QueryTranslation asQuery(BinaryExpression e, boolean onAggs) {
@ -449,7 +444,7 @@ class Likes extends ExppressionTranslator<BinaryExpression> {
}
}
class StringQueries extends ExppressionTranslator<StringQueryPredicate> {
static class StringQueries extends ExppressionTranslator<StringQueryPredicate> {
@Override
protected QueryTranslation asQuery(StringQueryPredicate q, boolean onAggs) {
@ -457,7 +452,7 @@ class StringQueries extends ExppressionTranslator<StringQueryPredicate> {
}
}
class Matches extends ExppressionTranslator<MatchQueryPredicate> {
static class Matches extends ExppressionTranslator<MatchQueryPredicate> {
@Override
protected QueryTranslation asQuery(MatchQueryPredicate q, boolean onAggs) {
@ -465,7 +460,7 @@ class Matches extends ExppressionTranslator<MatchQueryPredicate> {
}
}
class MultiMatches extends ExppressionTranslator<MultiMatchQueryPredicate> {
static class MultiMatches extends ExppressionTranslator<MultiMatchQueryPredicate> {
@Override
protected QueryTranslation asQuery(MultiMatchQueryPredicate q, boolean onAggs) {
@ -473,7 +468,7 @@ class MultiMatches extends ExppressionTranslator<MultiMatchQueryPredicate> {
}
}
class BinaryLogic extends ExppressionTranslator<BinaryExpression> {
static class BinaryLogic extends ExppressionTranslator<BinaryExpression> {
@Override
protected QueryTranslation asQuery(BinaryExpression e, boolean onAggs) {
@ -488,7 +483,7 @@ class BinaryLogic extends ExppressionTranslator<BinaryExpression> {
}
}
class Nots extends ExppressionTranslator<Not> {
static class Nots extends ExppressionTranslator<Not> {
@Override
protected QueryTranslation asQuery(Not not, boolean onAggs) {
@ -498,7 +493,7 @@ class Nots extends ExppressionTranslator<Not> {
}
// assume the Optimizer properly orders the predicates to ease the translation
class BinaryComparisons extends ExppressionTranslator<BinaryComparison> {
static class BinaryComparisons extends ExppressionTranslator<BinaryComparison> {
@Override
protected QueryTranslation asQuery(BinaryComparison bc, boolean onAggs) {
@ -602,7 +597,7 @@ class BinaryComparisons extends ExppressionTranslator<BinaryComparison> {
}
}
class Ranges extends ExppressionTranslator<Range> {
static class Ranges extends ExppressionTranslator<Range> {
@Override
protected QueryTranslation asQuery(Range r, boolean onAggs) {
@ -700,7 +695,7 @@ class Ranges extends ExppressionTranslator<Range> {
// Agg translators
//
class DistinctCounts extends SingleValueAggTranslator<Count> {
static class DistinctCounts extends SingleValueAggTranslator<Count> {
@Override
protected LeafAgg toAgg(String id, String path, Count c) {
@ -711,7 +706,7 @@ class DistinctCounts extends SingleValueAggTranslator<Count> {
}
}
class Sums extends SingleValueAggTranslator<Sum> {
static class Sums extends SingleValueAggTranslator<Sum> {
@Override
protected LeafAgg toAgg(String id, String path, Sum s) {
@ -719,7 +714,7 @@ class Sums extends SingleValueAggTranslator<Sum> {
}
}
class Avgs extends SingleValueAggTranslator<Avg> {
static class Avgs extends SingleValueAggTranslator<Avg> {
@Override
protected LeafAgg toAgg(String id, String path, Avg a) {
@ -727,7 +722,7 @@ class Avgs extends SingleValueAggTranslator<Avg> {
}
}
class Maxes extends SingleValueAggTranslator<Max> {
static class Maxes extends SingleValueAggTranslator<Max> {
@Override
protected LeafAgg toAgg(String id, String path, Max m) {
@ -735,7 +730,7 @@ class Maxes extends SingleValueAggTranslator<Max> {
}
}
class Mins extends SingleValueAggTranslator<Min> {
static class Mins extends SingleValueAggTranslator<Min> {
@Override
protected LeafAgg toAgg(String id, String path, Min m) {
@ -743,7 +738,7 @@ class Mins extends SingleValueAggTranslator<Min> {
}
}
class DateTimes extends SingleValueAggTranslator<Min> {
static class DateTimes extends SingleValueAggTranslator<Min> {
@Override
protected LeafAgg toAgg(String id, String path, Min m) {
@ -751,7 +746,7 @@ class DateTimes extends SingleValueAggTranslator<Min> {
}
}
abstract class SingleValueAggTranslator<F extends Function> extends AggTranslator<F> {
abstract static class SingleValueAggTranslator<F extends Function> extends AggTranslator<F> {
@Override
protected final LeafAgg asAgg(String id, String parent, F f) {
@ -762,7 +757,7 @@ abstract class SingleValueAggTranslator<F extends Function> extends AggTranslato
protected abstract LeafAgg toAgg(String id, String path, F f);
}
abstract class AggTranslator<F extends Function> {
abstract static class AggTranslator<F extends Function> {
private final Class<F> typeToken = ReflectionUtils.detectSuperTypeForRuleLike(getClass());
@ -774,7 +769,7 @@ abstract class AggTranslator<F extends Function> {
protected abstract LeafAgg asAgg(String id, String parent, F f);
}
abstract class ExppressionTranslator<E extends Expression> {
abstract static class ExppressionTranslator<E extends Expression> {
private final Class<E> typeToken = ReflectionUtils.detectSuperTypeForRuleLike(getClass());
@ -793,3 +788,4 @@ abstract class ExppressionTranslator<E extends Expression> {
return query;
}
}
}

View File

@ -20,7 +20,7 @@ abstract class Verifier {
private final Node<?> source;
private final String message;
public Failure(Node<?> source, String message) {
Failure(Node<?> source, String message) {
this.source = source;
this.message = message + " " + source.nodeString();
}

View File

@ -9,7 +9,7 @@ import org.elasticsearch.xpack.sql.type.Schema;
class EmptyRowSetCursor extends AbstractRowSetCursor {
public EmptyRowSetCursor(Schema schema) {
EmptyRowSetCursor(Schema schema) {
super(schema, null);
}

View File

@ -20,7 +20,7 @@ import static java.util.Collections.emptyList;
public class Schema implements Iterable<Entry> {
public static interface Entry {
public interface Entry {
String name();
DataType type();
}