SQL: Break long lines in expression package (elastic/x-pack-elasticsearch#3456)
Break lines over 140 characters in the expression package to make them a bit easier to read and to make checkstyle happy. Original commit: elastic/x-pack-elasticsearch@89487a79cc
This commit is contained in:
parent
c52b3350ef
commit
bc8103e268
|
@ -8,12 +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[/\\]expression[/\\]Attribute.java" checks="LineLength" />
|
||||
<suppress files="sql[/\\]server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]sql[/\\]expression[/\\]ExpressionIdGenerator.java" checks="LineLength" />
|
||||
<suppress files="sql[/\\]server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]sql[/\\]expression[/\\]FieldAttribute.java" checks="LineLength" />
|
||||
<suppress files="sql[/\\]server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]sql[/\\]expression[/\\]LiteralAttribute.java" checks="LineLength" />
|
||||
<suppress files="sql[/\\]server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]sql[/\\]expression[/\\]TypedAttribute.java" checks="LineLength" />
|
||||
<suppress files="sql[/\\]server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]sql[/\\]expression[/\\]UnresolvedAttribute.java" checks="LineLength" />
|
||||
<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[/\\]planner[/\\]PlanningException.java" checks="LineLength" />
|
||||
|
|
|
@ -59,26 +59,32 @@ public abstract class Attribute extends NamedExpression {
|
|||
}
|
||||
|
||||
public Attribute withLocation(Location location) {
|
||||
return Objects.equals(location(), location) ? this : clone(location, name(), dataType(), qualifier(), nullable(), id(), synthetic());
|
||||
return Objects.equals(location(), location) ? this : clone(location, name(), dataType(), qualifier(),
|
||||
nullable(), id(), synthetic());
|
||||
}
|
||||
|
||||
public Attribute withQualifier(String qualifier) {
|
||||
return Objects.equals(qualifier(), qualifier) ? this : clone(location(), name(), dataType(), qualifier, nullable(), id(), synthetic());
|
||||
return Objects.equals(qualifier(), qualifier) ? this : clone(location(), name(), dataType(), qualifier,
|
||||
nullable(), id(), synthetic());
|
||||
}
|
||||
|
||||
public Attribute withName(String name) {
|
||||
return Objects.equals(name(), name) ? this : clone(location(), name, dataType(), qualifier(), nullable(), id(), synthetic());
|
||||
return Objects.equals(name(), name) ? this : clone(location(), name, dataType(), qualifier(), nullable(),
|
||||
id(), synthetic());
|
||||
}
|
||||
|
||||
public Attribute withNullability(boolean nullable) {
|
||||
return Objects.equals(nullable(), nullable) ? this : clone(location(), name(), dataType(), qualifier(), nullable, id(), synthetic());
|
||||
return Objects.equals(nullable(), nullable) ? this : clone(location(), name(), dataType(), qualifier(),
|
||||
nullable, id(), synthetic());
|
||||
}
|
||||
|
||||
public Attribute withId(ExpressionId id) {
|
||||
return Objects.equals(id(), id) ? this : clone(location(), name(), dataType(), qualifier(), nullable(), id, synthetic());
|
||||
return Objects.equals(id(), id) ? this : clone(location(), name(), dataType(), qualifier(), nullable(),
|
||||
id, synthetic());
|
||||
}
|
||||
|
||||
protected abstract Attribute clone(Location location, String name, DataType dataType, String qualifier, boolean nullable, ExpressionId id, boolean synthetic);
|
||||
protected abstract Attribute clone(Location location, String name, DataType dataType, String qualifier,
|
||||
boolean nullable, ExpressionId id, boolean synthetic);
|
||||
|
||||
@Override
|
||||
public Attribute toAttribute() {
|
||||
|
|
|
@ -8,7 +8,8 @@ package org.elasticsearch.xpack.sql.expression;
|
|||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
//TODO: this class is thread-safe but used across multiple sessions might cause the id to roll over and potentially generate an already assigned id
|
||||
//TODO: this class is thread-safe but used across multiple sessions might cause the
|
||||
// id to roll over and potentially generate an already assigned id
|
||||
// making this session scope would simplify things
|
||||
// (which also begs the question on whether thread-safety is needed than)
|
||||
|
||||
|
|
|
@ -109,7 +109,8 @@ public class FieldAttribute extends TypedAttribute {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Attribute clone(Location location, String name, DataType dataType, String qualifier, boolean nullable, ExpressionId id, boolean synthetic) {
|
||||
protected Attribute clone(Location location, String name, DataType dataType, String qualifier, boolean nullable,
|
||||
ExpressionId id, boolean synthetic) {
|
||||
FieldAttribute qualifiedParent = parent != null ? (FieldAttribute) parent.withQualifier(qualifier) : null;
|
||||
return new FieldAttribute(location, qualifiedParent, name, dataType, qualifier, nullable, id, synthetic);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ public class LiteralAttribute extends TypedAttribute {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected LiteralAttribute clone(Location location, String name, DataType dataType, String qualifier, boolean nullable, ExpressionId id, boolean synthetic) {
|
||||
protected LiteralAttribute clone(Location location, String name, DataType dataType, String qualifier, boolean nullable,
|
||||
ExpressionId id, boolean synthetic) {
|
||||
return new LiteralAttribute(location, name, qualifier, nullable, id, synthetic, dataType, literal);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,8 @@ public abstract class TypedAttribute extends Attribute {
|
|||
this(location, name, dataType, null, true, null, false);
|
||||
}
|
||||
|
||||
protected TypedAttribute(Location location, String name, DataType dataType, String qualifier, boolean nullable, ExpressionId id, boolean synthetic) {
|
||||
protected TypedAttribute(Location location, String name, DataType dataType, String qualifier, boolean nullable,
|
||||
ExpressionId id, boolean synthetic) {
|
||||
super(location, name, qualifier, nullable, id, synthetic);
|
||||
this.dataType = dataType;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,8 @@ public class UnresolvedAttribute extends Attribute implements Unresolvable {
|
|||
this(location, name, qualifier, null, unresolvedMessage, null);
|
||||
}
|
||||
|
||||
public UnresolvedAttribute(Location location, String name, String qualifier, ExpressionId id, String unresolvedMessage, Object resolutionMetadata) {
|
||||
public UnresolvedAttribute(Location location, String name, String qualifier, ExpressionId id, String unresolvedMessage,
|
||||
Object resolutionMetadata) {
|
||||
super(location, name, qualifier, id);
|
||||
this.customMessage = unresolvedMessage != null;
|
||||
this.unresolvedMsg = unresolvedMessage == null ? errorMessage(qualifiedName(), null) : unresolvedMessage;
|
||||
|
@ -58,7 +59,8 @@ public class UnresolvedAttribute extends Attribute implements Unresolvable {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Attribute clone(Location location, String name, DataType dataType, String qualifier, boolean nullable, ExpressionId id, boolean synthetic) {
|
||||
protected Attribute clone(Location location, String name, DataType dataType, String qualifier, boolean nullable,
|
||||
ExpressionId id, boolean synthetic) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -94,7 +96,8 @@ public class UnresolvedAttribute extends Attribute implements Unresolvable {
|
|||
public static String errorMessage(String name, List<String> potentialMatches) {
|
||||
String msg = "Unknown column [" + name + "]";
|
||||
if (!CollectionUtils.isEmpty(potentialMatches)) {
|
||||
msg += ", did you mean " + (potentialMatches.size() == 1 ? "[" + potentialMatches.get(0) + "]": "any of " + potentialMatches.toString()) + "?";
|
||||
msg += ", did you mean " + (potentialMatches.size() == 1 ? "[" + potentialMatches.get(0)
|
||||
+ "]": "any of " + potentialMatches.toString()) + "?";
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue