Skip to content

Commit d6446a9

Browse files
fix: declare constants as final
Some public static constants were not declared final, allowing them to be incorrectly modified runtime. This change adds the final modifier to these constants. Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
1 parent 8553144 commit d6446a9

6 files changed

Lines changed: 17 additions & 17 deletions

File tree

isthmus/src/main/java/io/substrait/isthmus/AggregateFunctions.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@
2121
public class AggregateFunctions {
2222

2323
/** Substrait-specific MIN aggregate function (nullable return type). */
24-
public static SqlAggFunction MIN = new SubstraitSqlMinMaxAggFunction(SqlKind.MIN);
24+
public static final SqlAggFunction MIN = new SubstraitSqlMinMaxAggFunction(SqlKind.MIN);
2525

2626
/** Substrait-specific MAX aggregate function (nullable return type). */
27-
public static SqlAggFunction MAX = new SubstraitSqlMinMaxAggFunction(SqlKind.MAX);
27+
public static final SqlAggFunction MAX = new SubstraitSqlMinMaxAggFunction(SqlKind.MAX);
2828

2929
/** Substrait-specific AVG aggregate function (nullable return type). */
30-
public static SqlAggFunction AVG = new SubstraitAvgAggFunction(SqlKind.AVG);
30+
public static final SqlAggFunction AVG = new SubstraitAvgAggFunction(SqlKind.AVG);
3131

3232
/** Substrait-specific SUM aggregate function (nullable return type). */
33-
public static SqlAggFunction SUM = new SubstraitSumAggFunction();
33+
public static final SqlAggFunction SUM = new SubstraitSumAggFunction();
3434

3535
/** Substrait-specific SUM0 aggregate function (non-null BIGINT return type). */
36-
public static SqlAggFunction SUM0 = new SubstraitSumEmptyIsZeroAggFunction();
36+
public static final SqlAggFunction SUM0 = new SubstraitSumEmptyIsZeroAggFunction();
3737

3838
/**
3939
* Converts default Calcite aggregate functions to Substrait-specific variants when needed.

isthmus/src/main/java/io/substrait/isthmus/TypeConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class TypeConverter {
4040
* <p>Both {@link UserTypeMapper#toSubstrait(RelDataType)} and {@link
4141
* UserTypeMapper#toCalcite(Type.UserDefined)} return {@code null} in this default configuration.
4242
*/
43-
public static TypeConverter DEFAULT =
43+
public static final TypeConverter DEFAULT =
4444
new TypeConverter(
4545
new UserTypeMapper() {
4646
@Nullable

isthmus/src/main/java/io/substrait/isthmus/calcite/SubstraitOperatorTable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
public class SubstraitOperatorTable implements SqlOperatorTable {
3333

3434
/** Singleton instance of the Substrait operator table. */
35-
public static SubstraitOperatorTable INSTANCE = new SubstraitOperatorTable();
35+
public static final SubstraitOperatorTable INSTANCE = new SubstraitOperatorTable();
3636

3737
private static final SqlOperatorTable SUBSTRAIT_OPERATOR_TABLE =
3838
SqlOperatorTables.of(

isthmus/src/main/java/io/substrait/isthmus/expression/CallConverters.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class CallConverters {
4040
*
4141
* @see ExpressionCreator#cast(Type, Expression, Expression.FailureBehavior)
4242
*/
43-
public static Function<TypeConverter, SimpleCallConverter> CAST =
43+
public static final Function<TypeConverter, SimpleCallConverter> CAST =
4444
typeConverter ->
4545
(call, visitor) -> {
4646
Expression.FailureBehavior failureBehavior;
@@ -78,7 +78,7 @@ public class CallConverters {
7878
* <p>When converting from Calcite to Substrait, this call converter extracts the stored {@link
7979
* Expression.UserDefinedLiteral}.
8080
*/
81-
public static Function<TypeConverter, SimpleCallConverter> REINTERPRET =
81+
public static final Function<TypeConverter, SimpleCallConverter> REINTERPRET =
8282
typeConverter ->
8383
(call, visitor) -> {
8484
if (call.getKind() != SqlKind.REINTERPRET) {
@@ -136,7 +136,7 @@ else if (operand instanceof Expression.StructLiteral
136136
*
137137
* <p>Each literal's nullability is set to match its field type's nullability.
138138
*/
139-
public static SimpleCallConverter ROW =
139+
public static final SimpleCallConverter ROW =
140140
(call, visitor) -> {
141141
if (call.getKind() != SqlKind.ROW) {
142142
return null;
@@ -189,7 +189,7 @@ else if (operand instanceof Expression.StructLiteral
189189
* <p>This converter assumes that operand expressions have already been converted by the provided
190190
* top-level visitor.
191191
*/
192-
public static SimpleCallConverter CASE =
192+
public static final SimpleCallConverter CASE =
193193
(call, visitor) -> {
194194
if (call.getKind() != SqlKind.CASE) {
195195
return null;
@@ -225,7 +225,7 @@ else if (operand instanceof Expression.StructLiteral
225225
* <p>Returns a {@link SimpleCallConverter} that expands SEARCH calls using the provided {@link
226226
* RexBuilder}
227227
*/
228-
public static Function<RexBuilder, SimpleCallConverter> CREATE_SEARCH_CONV =
228+
public static final Function<RexBuilder, SimpleCallConverter> CREATE_SEARCH_CONV =
229229
(RexBuilder rexBuilder) ->
230230
(RexCall call, Function<RexNode, Expression> visitor) -> {
231231
if (call.getKind() != SqlKind.SEARCH) {
@@ -247,7 +247,7 @@ else if (operand instanceof Expression.StructLiteral
247247
* <p>Matching is done on operator identity (these are niladic {@link SqlKind#OTHER_FUNCTION}
248248
* functions with no dedicated {@link SqlKind}).
249249
*/
250-
public static SimpleCallConverter EXECUTION_CONTEXT_VARIABLE =
250+
public static final SimpleCallConverter EXECUTION_CONTEXT_VARIABLE =
251251
(call, visitor) -> {
252252
if (call.getOperator() == SqlStdOperatorTable.CURRENT_TIMESTAMP) {
253253
return ExpressionCreator.currentTimestamp(call.getType().getPrecision());

isthmus/src/main/java/io/substrait/isthmus/sql/SubstraitSqlDialect.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
public class SubstraitSqlDialect extends SqlDialect {
1616

1717
/** Default context for the Substrait SQL dialect. */
18-
public static SqlDialect.Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT;
18+
public static final SqlDialect.Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT;
1919

2020
/** Default instance of Substrait SQL dialect. */
21-
public static SqlDialect DEFAULT = new SubstraitSqlDialect(DEFAULT_CONTEXT);
21+
public static final SqlDialect DEFAULT = new SubstraitSqlDialect(DEFAULT_CONTEXT);
2222

2323
/**
2424
* Converts a Calcite {@link RelNode} to its SQL representation using the default dialect.

isthmus/src/test/java/io/substrait/isthmus/RelCopyOnWriteVisitorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727

2828
class RelCopyOnWriteVisitorTest extends PlanTestBase {
2929

30-
public static SimpleExtension.FunctionAnchor APPROX_COUNT_DISTINCT =
30+
public static final SimpleExtension.FunctionAnchor APPROX_COUNT_DISTINCT =
3131
SimpleExtension.FunctionAnchor.of(
3232
"extension:io.substrait:functions_aggregate_approx", "approx_count_distinct:any");
33-
public static SimpleExtension.FunctionAnchor COUNT =
33+
public static final SimpleExtension.FunctionAnchor COUNT =
3434
SimpleExtension.FunctionAnchor.of(
3535
"extension:io.substrait:functions_aggregate_generic", "count:any");
3636

0 commit comments

Comments
 (0)