Skip to content

Commit

Permalink
Enable ErrorProne TraditionalSwitchExpression
Browse files Browse the repository at this point in the history
  • Loading branch information
ebyhr authored and wendigo committed Oct 4, 2024
1 parent c9da5cd commit 33f54c9
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,9 @@ public ConnectorPageSource createPageSource(
DeltaLakeColumnMetadata partitionColumn = columnsMetadataByName.get(partitionColumnName);
checkState(partitionColumn != null, "Partition column %s not found", partitionColumnName);
Optional<String> value = switch (columnMappingMode) {
case NONE:
yield partitionKeys.get(partitionColumn.name());
case ID, NAME:
yield partitionKeys.get(partitionColumn.physicalName());
default:
throw new IllegalStateException("Unknown column mapping mode");
case NONE -> partitionKeys.get(partitionColumn.name());
case ID, NAME -> partitionKeys.get(partitionColumn.physicalName());
default -> throw new IllegalStateException("Unknown column mapping mode");
};
// Fill partition values in the same order as the partition columns are specified in the table definition
partitionValues.get().add(value.orElse(null));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,13 @@ public Object visitColumnReference(SparkExpressionBaseParser.ColumnReferenceCont
private static ComparisonExpression.Operator getComparisonOperator(Token symbol)
{
return switch (symbol.getType()) {
case SparkExpressionBaseLexer.EQ:
yield ComparisonExpression.Operator.EQUAL;
case SparkExpressionBaseLexer.NEQ:
yield ComparisonExpression.Operator.NOT_EQUAL;
case SparkExpressionBaseLexer.LT:
yield ComparisonExpression.Operator.LESS_THAN;
case SparkExpressionBaseLexer.LTE:
yield ComparisonExpression.Operator.LESS_THAN_OR_EQUAL;
case SparkExpressionBaseLexer.GT:
yield ComparisonExpression.Operator.GREATER_THAN;
case SparkExpressionBaseLexer.GTE:
yield ComparisonExpression.Operator.GREATER_THAN_OR_EQUAL;
default:
throw new IllegalArgumentException("Unsupported operator: " + symbol.getText());
case SparkExpressionBaseLexer.EQ -> ComparisonExpression.Operator.EQUAL;
case SparkExpressionBaseLexer.NEQ -> ComparisonExpression.Operator.NOT_EQUAL;
case SparkExpressionBaseLexer.LT -> ComparisonExpression.Operator.LESS_THAN;
case SparkExpressionBaseLexer.LTE -> ComparisonExpression.Operator.LESS_THAN_OR_EQUAL;
case SparkExpressionBaseLexer.GT -> ComparisonExpression.Operator.GREATER_THAN;
case SparkExpressionBaseLexer.GTE -> ComparisonExpression.Operator.GREATER_THAN_OR_EQUAL;
default -> throw new IllegalArgumentException("Unsupported operator: " + symbol.getText());
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,14 @@ public Schema getSchema()
public Object get(int field)
{
return switch (field) {
case 0:
yield baseInstantTime;
case 1:
yield deltaFilePaths;
case 2:
yield dataFilePath;
case 3:
yield fileId;
case 4:
yield partitionPath;
case 5:
yield metrics;
case 6:
yield bootstrapFilePath;
default:
throw new IndexOutOfBoundsException("Invalid index: " + field);
case 0 -> baseInstantTime;
case 1 -> deltaFilePaths;
case 2 -> dataFilePath;
case 3 -> fileId;
case 4 -> partitionPath;
case 5 -> metrics;
case 6 -> bootstrapFilePath;
default -> throw new IndexOutOfBoundsException("Invalid index: " + field);
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,10 @@ public Integer getVersion()
public Object get(int field)
{
return switch (field) {
case 0:
yield operations;
case 1:
yield extraMetadata;
case 2:
yield version;
default:
throw new IndexOutOfBoundsException("Invalid index: " + field);
case 0 -> operations;
case 1 -> extraMetadata;
case 2 -> version;
default -> throw new IndexOutOfBoundsException("Invalid index: " + field);
};
}

Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2890,6 +2890,7 @@
-Xep:StringCaseLocaleUsage:ERROR \
-Xep:SuppressWarningsDeprecated:ERROR \
-Xep:ThreeLetterTimeZoneID:ERROR \
-Xep:TraditionalSwitchExpression:ERROR \
-Xep:UnicodeEscape:ERROR \
-Xep:UnnecessaryLongToIntConversion:ERROR \
-Xep:UnnecessaryMethodReference:ERROR \
Expand Down

0 comments on commit 33f54c9

Please sign in to comment.