SQL: wrap remaining long lines (elastic/x-pack-elasticsearch#3458)

Wrap all remaining lines over 140 characters in sql for easier
readability.

Original commit: elastic/x-pack-elasticsearch@e0bc04a049
This commit is contained in:
Nik Everett 2018-01-01 13:42:38 -05:00 committed by GitHub
parent 1cc64f4ca1
commit a7728e5caa
4 changed files with 34 additions and 19 deletions

View File

@ -8,10 +8,6 @@
<!-- These files are generated by ANTLR so its silly to hold them to our rules. -->
<suppress files="sql[/\\]server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]sql[/\\]parser[/\\]SqlBase(Base(Listener|Visitor)|Lexer|Listener|Parser|Visitor).java" checks="." />
<suppress files="sql[/\\]server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]sql[/\\]optimizer[/\\]Optimizer.java" checks="LineLength" />
<suppress files="sql[/\\]server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]sql[/\\]plan[/\\]logical[/\\]command[/\\]Explain.java" checks="LineLength" />
<suppress files="sql[/\\]server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]sql[/\\]tree[/\\]NodeUtils.java" checks="LineLength" />
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]common[/\\]action[/\\]XPackDeleteByQueryAction.java" checks="LineLength" />
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]action[/\\]StopDatafeedAction.java" checks="LineLength" />
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]utils[/\\]DomainSplitFunction.java" checks="LineLength" />

View File

@ -317,7 +317,8 @@ public class Optimizer extends RuleExecutor<LogicalPlan> {
return e;
}
protected Expression rule(Expression e, Map<Expression, ExtendedStats> seen, Map<String, AggregateFunctionAttribute> promotedIds) {
protected Expression rule(Expression e, Map<Expression, ExtendedStats> seen,
Map<String, AggregateFunctionAttribute> promotedIds) {
if (e instanceof ExtendedStatsEnclosed) {
AggregateFunction f = (AggregateFunction) e;
@ -582,7 +583,8 @@ public class Optimizer extends RuleExecutor<LogicalPlan> {
}
}
protected Expression rule(Expression e, Map<Expression, Percentiles> percentilesPerField, Map<String, AggregateFunctionAttribute> promotedIds) {
protected Expression rule(Expression e, Map<Expression, Percentiles> percentilesPerField,
Map<String, AggregateFunctionAttribute> promotedIds) {
if (e instanceof Percentile) {
Percentile p = (Percentile) e;
Percentiles percentiles = percentilesPerField.get(p.field());
@ -639,7 +641,8 @@ public class Optimizer extends RuleExecutor<LogicalPlan> {
}
}
protected Expression rule(Expression e, Map<Expression, PercentileRanks> ranksPerField, Map<String, AggregateFunctionAttribute> promotedIds) {
protected Expression rule(Expression e, Map<Expression, PercentileRanks> ranksPerField,
Map<String, AggregateFunctionAttribute> promotedIds) {
if (e instanceof PercentileRank) {
PercentileRank p = (PercentileRank) e;
PercentileRanks ranks = ranksPerField.get(p.field());
@ -1034,7 +1037,12 @@ public class Optimizer extends RuleExecutor<LogicalPlan> {
}
private boolean canPropagateFoldable(LogicalPlan p) {
return p instanceof Project || p instanceof Filter || p instanceof SubQueryAlias || p instanceof Aggregate || p instanceof Limit || p instanceof OrderBy;
return p instanceof Project
|| p instanceof Filter
|| p instanceof SubQueryAlias
|| p instanceof Aggregate
|| p instanceof Limit
|| p instanceof OrderBy;
}
}
@ -1374,7 +1382,8 @@ public class Optimizer extends RuleExecutor<LogicalPlan> {
@Override
public final LogicalPlan apply(LogicalPlan plan) {
return direction == TransformDirection.DOWN ? plan.transformDown(this::rule, typeToken()) : plan.transformUp(this::rule, typeToken());
return direction == TransformDirection.DOWN ?
plan.transformDown(this::rule, typeToken()) : plan.transformUp(this::rule, typeToken());
}
@Override

View File

@ -117,7 +117,8 @@ public class Explain extends Command {
}
// Type.All
listener.onResponse(Rows.singleton(output(), printPlans(format, plan, analyzedPlan, optimizedPlan, mappedPlan, executablePlan)));
listener.onResponse(Rows.singleton(output(), printPlans(format, plan, analyzedPlan, optimizedPlan,
mappedPlan, executablePlan)));
}, listener::onFailure));
}
@ -146,7 +147,8 @@ public class Explain extends Command {
return;
}
listener.onResponse(Rows.singleton(output(), printPlans(format, plan, analyzedPlan, optimizedPlan, mappedPlan, executablePlan)));
listener.onResponse(Rows.singleton(output(), printPlans(format, plan, analyzedPlan, optimizedPlan,
mappedPlan, executablePlan)));
return;
}
// mapped failed
@ -155,7 +157,8 @@ public class Explain extends Command {
return;
}
listener.onResponse(Rows.singleton(output(), printPlans(format, plan, analyzedPlan, optimizedPlan, mappedPlan, null)));
listener.onResponse(Rows.singleton(output(), printPlans(format, plan, analyzedPlan, optimizedPlan,
mappedPlan, null)));
}, listener::onFailure));
// cannot continue
} else {
@ -170,7 +173,8 @@ public class Explain extends Command {
}, listener::onFailure));
}
private static String printPlans(Format format, LogicalPlan parsed, LogicalPlan analyzedPlan, LogicalPlan optimizedPlan, PhysicalPlan mappedPlan, PhysicalPlan executionPlan) {
private static String printPlans(Format format, LogicalPlan parsed, LogicalPlan analyzedPlan, LogicalPlan optimizedPlan,
PhysicalPlan mappedPlan, PhysicalPlan executionPlan) {
if (format == Format.TEXT) {
StringBuilder sb = new StringBuilder();
sb.append("Parsed\n");

View File

@ -78,7 +78,8 @@ public abstract class NodeUtils {
// basic sanity check
List<T> currentChildren = tree.children();
Check.isTrue(currentChildren.size() == newChildren.size(), "Cannot make copy; expected %s children but received %s", currentChildren.size(), newChildren.size());
Check.isTrue(currentChildren.size() == newChildren.size(), "Cannot make copy; expected %s children but received %s",
currentChildren.size(), newChildren.size());
NodeInfo info = info(tree.getClass());
Object[] props = properties(tree, info);
@ -151,7 +152,9 @@ public abstract class NodeUtils {
Parameter[] parameters = ctr.getParameters();
for (int paramIndex = 0; paramIndex < parameters.length; paramIndex++) {
Parameter param = parameters[paramIndex];
Check.isTrue(param.isNamePresent(), "Can't find constructor parameter names for [%s]. Is class debug information available?", clazz.toGenericString());
Check.isTrue(param.isNamePresent(),
"Can't find constructor parameter names for [%s]. Is class debug information available?",
clazz.toGenericString());
String paramName = param.getName();
if (paramName.equals("children")) {
@ -162,7 +165,8 @@ public abstract class NodeUtils {
try {
getter = clazz.getMethod(paramName);
} catch (NoSuchMethodException nsme) {
throw new SqlIllegalArgumentException("class [%s] expected to have method [%s] for retrieving constructor arguments; none found",
throw new SqlIllegalArgumentException(
"class [%s] expected to have method [%s] for retrieving constructor arguments; none found",
clazz.getName(), paramName);
}
@ -170,7 +174,9 @@ public abstract class NodeUtils {
Class<?> expected = param.getType();
Class<?> found = getter.getReturnType();
// found == Object if we're dealing with generics
Check.isTrue(found == Object.class || expected.isAssignableFrom(found), "Constructor param [%s] in class [%s] has type [%s] but found getter [%s]", paramName, clazz, expected, getter.toGenericString());
Check.isTrue(found == Object.class || expected.isAssignableFrom(found),
"Constructor param [%s] in class [%s] has type [%s] but found getter [%s]", paramName, clazz,
expected, getter.toGenericString());
params.put(paramName, getter);
}