Skip to content

build: use JSpecify @Nullable instead of JSR305 #444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ dependencies {
implementation("com.fasterxml.jackson.core:jackson-annotations:${JACKSON_VERSION}")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${JACKSON_VERSION}")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${JACKSON_VERSION}")
implementation("com.google.code.findbugs:jsr305:3.0.2")
api("org.jspecify:jspecify:1.0.0")

antlr("org.antlr:antlr4:${ANTLR_VERSION}")
shadowImplementation("org.antlr:antlr4-runtime:${ANTLR_VERSION}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import javax.annotation.Nullable;
import org.immutables.value.Value;
import org.jspecify.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -79,12 +79,10 @@ public interface Argument {
String toTypeString();

@JsonProperty()
@Nullable
String name();
@Nullable String name();

@JsonProperty()
@Nullable
String description();
@Nullable String description();

boolean required();
}
Expand Down
2 changes: 1 addition & 1 deletion isthmus/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ dependencies {
exclude("com.google.guava", "guava")
.because("Brings in Guava for Android, which we don't want (and breaks multimaps).")
}
implementation("com.google.code.findbugs:jsr305:3.0.2")
implementation("org.immutables:value-annotations:${IMMUTABLES_VERSION}")
implementation("org.slf4j:slf4j-api:${SLF4J_VERSION}")
annotationProcessor("org.immutables:value:${IMMUTABLES_VERSION}")
Expand All @@ -150,6 +149,7 @@ dependencies {
)
}
testImplementation("com.google.protobuf:protobuf-java:${PROTOBUF_VERSION}")
api("org.jspecify:jspecify:1.0.0")
}

tasks {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nullable;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rel.type.RelDataTypeFactory;
import org.apache.calcite.sql.type.MapSqlType;
import org.apache.calcite.sql.type.SqlTypeName;
import org.jspecify.annotations.Nullable;

public class TypeConverter {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
package io.substrait.isthmus;

import io.substrait.type.Type;
import javax.annotation.Nullable;
import org.apache.calcite.rel.type.RelDataType;
import org.jspecify.annotations.Nullable;

/** Defines conversion of user-defined types between Substrait and Calcite */
public interface UserTypeMapper {
/**
* @param relDataType the Calcite {@link RelDataType} type to convert
* @return the Substrait representation of the input type
*/
@Nullable
Type toSubstrait(RelDataType relDataType);
@Nullable Type toSubstrait(RelDataType relDataType);

/**
* @param type the Subtrait {@link Type.UserDefined} type to convert
* @return the Calcite {@link RelDataType} representing the input type
*/
@Nullable
RelDataType toCalcite(Type.UserDefined type);
@Nullable RelDataType toCalcite(Type.UserDefined type);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.apache.calcite.sql.fun.SqlStdOperatorTable;
import org.apache.calcite.sql.util.SqlOperatorTables;
import org.apache.calcite.sql.validate.SqlNameMatcher;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jspecify.annotations.Nullable;

/**
* Overrides SQL operator lookups to return Substrait specific functions variants (e.g. {@link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
import javax.annotation.Nullable;
import org.apache.calcite.rex.RexBuilder;
import org.apache.calcite.rex.RexCall;
import org.apache.calcite.rex.RexNode;
import org.apache.calcite.rex.RexUtil;
import org.apache.calcite.sql.SqlKind;
import org.jspecify.annotations.Nullable;

public class CallConverters {

Expand Down Expand Up @@ -146,8 +146,7 @@ public static List<CallConverter> defaults(TypeConverter typeConverter) {

public interface SimpleCallConverter extends CallConverter {

@Nullable
Expression apply(RexCall call, Function<RexNode, Expression> topLevelConverter);
@Nullable Expression apply(RexCall call, Function<RexNode, Expression> topLevelConverter);

@Override
default Optional<Expression> convert(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import io.substrait.type.TypeCreator;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nullable;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.sql.type.SqlTypeName;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.apache.calcite.rel.externalize.RelWriterImpl;
import org.apache.calcite.sql.SqlExplainLevel;
import org.apache.calcite.util.Pair;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;

public class ComplexSortTest extends PlanTestBase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import io.substrait.type.TypeCreator;
import java.io.IOException;
import java.util.List;
import javax.annotation.Nullable;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rel.type.RelDataTypeFactory;
Expand All @@ -34,6 +33,7 @@
import org.apache.calcite.sql.type.SqlTypeFactoryImpl;
import org.apache.calcite.sql.type.SqlTypeName;
import org.apache.calcite.tools.RelBuilder;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;

/** Verify that custom functions can convert from Substrait to Calcite and back. */
Expand Down
Loading