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:
parent
1cc64f4ca1
commit
a7728e5caa
|
@ -8,10 +8,6 @@
|
||||||
<!-- These files are generated by ANTLR so its silly to hold them to our rules. -->
|
<!-- 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[/\\]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[/\\]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[/\\]action[/\\]StopDatafeedAction.java" checks="LineLength" />
|
||||||
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]utils[/\\]DomainSplitFunction.java" checks="LineLength" />
|
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]utils[/\\]DomainSplitFunction.java" checks="LineLength" />
|
||||||
|
|
|
@ -317,7 +317,8 @@ public class Optimizer extends RuleExecutor<LogicalPlan> {
|
||||||
return e;
|
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) {
|
if (e instanceof ExtendedStatsEnclosed) {
|
||||||
AggregateFunction f = (AggregateFunction) e;
|
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) {
|
if (e instanceof Percentile) {
|
||||||
Percentile p = (Percentile) e;
|
Percentile p = (Percentile) e;
|
||||||
Percentiles percentiles = percentilesPerField.get(p.field());
|
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) {
|
if (e instanceof PercentileRank) {
|
||||||
PercentileRank p = (PercentileRank) e;
|
PercentileRank p = (PercentileRank) e;
|
||||||
PercentileRanks ranks = ranksPerField.get(p.field());
|
PercentileRanks ranks = ranksPerField.get(p.field());
|
||||||
|
@ -1034,7 +1037,12 @@ public class Optimizer extends RuleExecutor<LogicalPlan> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canPropagateFoldable(LogicalPlan p) {
|
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
|
@Override
|
||||||
public final LogicalPlan apply(LogicalPlan plan) {
|
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
|
@Override
|
||||||
|
@ -1406,4 +1415,4 @@ public class Optimizer extends RuleExecutor<LogicalPlan> {
|
||||||
enum TransformDirection {
|
enum TransformDirection {
|
||||||
UP, DOWN
|
UP, DOWN
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,8 @@ public class Explain extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type.All
|
// 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));
|
}, listener::onFailure));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +147,8 @@ public class Explain extends Command {
|
||||||
return;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
// mapped failed
|
// mapped failed
|
||||||
|
@ -155,7 +157,8 @@ public class Explain extends Command {
|
||||||
return;
|
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));
|
}, listener::onFailure));
|
||||||
// cannot continue
|
// cannot continue
|
||||||
} else {
|
} else {
|
||||||
|
@ -170,7 +173,8 @@ public class Explain extends Command {
|
||||||
}, listener::onFailure));
|
}, 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) {
|
if (format == Format.TEXT) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("Parsed\n");
|
sb.append("Parsed\n");
|
||||||
|
|
|
@ -78,7 +78,8 @@ public abstract class NodeUtils {
|
||||||
|
|
||||||
// basic sanity check
|
// basic sanity check
|
||||||
List<T> currentChildren = tree.children();
|
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());
|
NodeInfo info = info(tree.getClass());
|
||||||
Object[] props = properties(tree, info);
|
Object[] props = properties(tree, info);
|
||||||
|
@ -151,7 +152,9 @@ public abstract class NodeUtils {
|
||||||
Parameter[] parameters = ctr.getParameters();
|
Parameter[] parameters = ctr.getParameters();
|
||||||
for (int paramIndex = 0; paramIndex < parameters.length; paramIndex++) {
|
for (int paramIndex = 0; paramIndex < parameters.length; paramIndex++) {
|
||||||
Parameter param = parameters[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();
|
String paramName = param.getName();
|
||||||
|
|
||||||
if (paramName.equals("children")) {
|
if (paramName.equals("children")) {
|
||||||
|
@ -162,7 +165,8 @@ public abstract class NodeUtils {
|
||||||
try {
|
try {
|
||||||
getter = clazz.getMethod(paramName);
|
getter = clazz.getMethod(paramName);
|
||||||
} catch (NoSuchMethodException nsme) {
|
} 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);
|
clazz.getName(), paramName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +174,9 @@ public abstract class NodeUtils {
|
||||||
Class<?> expected = param.getType();
|
Class<?> expected = param.getType();
|
||||||
Class<?> found = getter.getReturnType();
|
Class<?> found = getter.getReturnType();
|
||||||
// found == Object if we're dealing with generics
|
// 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);
|
params.put(paramName, getter);
|
||||||
}
|
}
|
||||||
|
@ -368,4 +374,4 @@ public abstract class NodeUtils {
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue