Skip to content

Commit

Permalink
[CALCITE-4314] Add missing default branches to switch statement
Browse files Browse the repository at this point in the history
Note: the changes are mechanical.
The intention is to keep the previous behavior and prevent adding new
non exchaustive switch statements in the future.

See https://errorprone.info/bugpattern/MissingCasesInEnumSwitch
  • Loading branch information
vlsi committed Oct 6, 2020
1 parent 69b12e0 commit 1b94f37
Show file tree
Hide file tree
Showing 98 changed files with 691 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ private static List wrap(ColumnMetaData.Rep rep, List list,
case JAVA_SQL_TIMESTAMP:
return Util.transform(list,
(Timestamp t) -> t == null ? null : t.getTime());
default:
break;
}
break;
case TIME:
Expand All @@ -248,6 +250,8 @@ private static List wrap(ColumnMetaData.Rep rep, List list,
return Util.transform(list, (Time t) -> t == null
? null
: (int) (t.getTime() % DateTimeUtils.MILLIS_PER_DAY));
default:
break;
}
break;
case DATE:
Expand All @@ -257,8 +261,12 @@ private static List wrap(ColumnMetaData.Rep rep, List list,
return Util.transform(list, (Date d) -> d == null
? null
: (int) (d.getTime() / DateTimeUtils.MILLIS_PER_DAY));
default:
break;
}
break;
default:
break;
}
return list;
}
Expand Down Expand Up @@ -322,6 +330,8 @@ ArrayTable.Representation chooseRep(int ordinal) {
case OTHER:
case VOID:
throw new AssertionError("wtf?!");
default:
break;
}
if (canBeLong(min) && canBeLong(max)) {
return chooseFixedRep(
Expand Down Expand Up @@ -415,6 +425,8 @@ private ArrayTable.Representation chooseFixedRep(
case 64:
return new ArrayTable.PrimitiveArray(
ordinal, Primitive.LONG, p);
default:
break;
}
}
return new ArrayTable.BitSlicedPrimitiveArray(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,8 @@ static JoinType toLinq4jJoinType(JoinRelType joinRelType) {
return JoinType.SEMI;
case ANTI:
return JoinType.ANTI;
default:
break;
}
throw new IllegalStateException(
"Unable to convert " + joinRelType + " to Linq4j JoinType");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ private Expression implementMeasure(RexToLixTranslator translator,
((PassedRowsInputGetter) translator.inputGetter).setIndex(null);
return matchImplementor.implement(translator, call, row_, rows_,
symbols_, i_);
default:
break;
}
return translator.translate(operands.get(0));

Expand Down Expand Up @@ -434,6 +436,8 @@ public int getFuture() {
final int next = operand.getValueAs(Integer.class);
this.future = Math.max(this.future, next);
break;
default:
break;
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ public ClassDeclaration implementRoot(EnumerableRel rootRel,
result = new EnumerableRel.Result(bb.toBlock(), result.physType,
JavaRowFormat.SCALAR);
}
break;
default:
break;
}

final List<MemberDeclaration> memberDeclarations = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ private boolean hasCollectionField(RelDataType rowType) {
case ARRAY:
case MULTISET:
return true;
default:
break;
}
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ static PhysType of(
case 1:
targetFormat = JavaRowFormat.SCALAR;
break;
default:
break;
}
final PhysType targetPhysType =
project(fields, targetFormat);
Expand Down Expand Up @@ -203,6 +205,8 @@ static PhysType of(
case 1:
targetFormat = JavaRowFormat.SCALAR;
break;
default:
break;
}
final PhysType targetPhysType =
project(fields, targetFormat);
Expand Down Expand Up @@ -312,6 +316,9 @@ static PhysType of(
case OBJECT:
arg0 = EnumUtils.convert(arg0, Comparable.class);
arg1 = EnumUtils.convert(arg1, Comparable.class);
break;
default:
break;
}
final boolean nullsFirst =
collation.nullDirection
Expand Down Expand Up @@ -415,6 +422,9 @@ static PhysType of(
case OBJECT:
arg0 = EnumUtils.convert(arg0, Comparable.class);
arg1 = EnumUtils.convert(arg1, Comparable.class);
break;
default:
break;
}
final boolean nullsFirst =
fieldCollation.nullDirection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -915,8 +915,12 @@ public Expression handle(Expression x) {
case NOT_POSSIBLE:
return EnumUtils.convert(x,
Primitive.ofBox(x.getType()).primitiveClass);
default:
break;
}
// fall through
break;
default:
break;
}
switch (this) {
case NULL:
Expand Down Expand Up @@ -2329,6 +2333,8 @@ private static class ExtractImplementor extends AbstractRexCallImplementor {
case INTERVAL_SECOND:
// no convertlet conversion, pass it as extract
throw new AssertionError("unexpected " + sqlTypeName);
default:
break;
}
break;
case HOUR:
Expand All @@ -2337,6 +2343,8 @@ private static class ExtractImplementor extends AbstractRexCallImplementor {
switch (sqlTypeName) {
case DATE:
return Expressions.multiply(operand, Expressions.constant(0L));
default:
break;
}
break;
}
Expand Down Expand Up @@ -2675,12 +2683,17 @@ private static class DatetimeArithmeticImplementor
Expressions.divide(trop1,
Expressions.constant(DateTimeUtils.MILLIS_PER_DAY)),
int.class);
break;
default:
break;
}
}
break;
case TIME:
trop1 = Expressions.convert_(trop1, int.class);
break;
default:
break;
}
switch (typeName1) {
case INTERVAL_YEAR:
Expand All @@ -2689,6 +2702,9 @@ private static class DatetimeArithmeticImplementor
switch (call.getKind()) {
case MINUS:
trop1 = Expressions.negate(trop1);
break;
default:
break;
}
switch (typeName) {
case TIME:
Expand Down Expand Up @@ -2727,6 +2743,8 @@ private static class DatetimeArithmeticImplementor
case INTERVAL_MONTH:
return Expressions.call(BuiltInMethod.SUBTRACT_MONTHS.method,
trop0, trop1);
default:
break;
}
TimeUnit fromUnit =
typeName1 == SqlTypeName.DATE ? TimeUnit.DAY : TimeUnit.MILLISECOND;
Expand Down
Loading

0 comments on commit 1b94f37

Please sign in to comment.