Skip to content

Commit

Permalink
CheckerFramework and ErrorProne fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
  • Loading branch information
mihaibudiu committed Sep 4, 2024
1 parent 258aa0a commit 5759a66
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
12 changes: 7 additions & 5 deletions core/src/main/java/org/apache/calcite/util/Variant.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
/** This class is the runtime support for values of the VARIANT SQL type. */
public class Variant {
/** Actual value. */
@Nullable
final Object value;
final @Nullable Object value;
/** Type of the value. */
final RuntimeTypeInformation runtimeType;
/** The VARIANT type has its own notion of null, which is
Expand Down Expand Up @@ -64,7 +63,7 @@ public boolean isVariantNull() {
return this.isVariantNull;
}

@Override public boolean equals(Object o) {
@Override public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}
Expand Down Expand Up @@ -105,7 +104,7 @@ public boolean isVariantNull() {
}

// This method is invoked from {@link RexToLixTranslator} VARIANT_CAST
@Nullable public static Object cast(@Nullable Object variant, RuntimeTypeInformation type) {
public static @Nullable Object cast(@Nullable Object variant, RuntimeTypeInformation type) {
if (variant == null) {
return null;
}
Expand All @@ -116,7 +115,7 @@ public boolean isVariantNull() {
}

// Implementation of the array index operator for VARIANT values
@Nullable public Object item(Object index) {
public @Nullable Object item(Object index) {
if (this.value == null) {
return null;
}
Expand Down Expand Up @@ -173,6 +172,9 @@ public boolean isVariantNull() {
// are printed with double quotes
// https://docs.snowflake.com/en/sql-reference/data-types-semistructured
quote = "\"";
break;
default:
break;
}
return quote + value + quote;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.calcite.util.rtti;

import org.checkerframework.checker.nullness.qual.Nullable;

/** Runtime type information about a base (primitive) SQL type. */
public class BasicSqlTypeRtti extends RuntimeTypeInformation {
private final int precision;
Expand All @@ -28,7 +30,7 @@ public BasicSqlTypeRtti(RuntimeSqlTypeName typeName, int precision, int scale) {
this.scale = scale;
}

@Override public boolean equals(Object o) {
@Override public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.calcite.util.rtti;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.Arrays;

/** Runtime type information which contains some type parameters. */
Expand Down Expand Up @@ -55,7 +57,7 @@ public String getTypeString() {
return builder.toString();
}

@Override public boolean equals(Object o) {
@Override public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.calcite.util.rtti;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.Arrays;
import java.util.Map;

Expand All @@ -28,7 +30,7 @@ public RowSqlTypeRtti(Map.Entry<String, RuntimeTypeInformation>... fieldNames) {
this.fieldNames = fieldNames;
}

public String getTypeString() {
@Override public String getTypeString() {
return "ROW";
}

Expand All @@ -49,7 +51,7 @@ public String getTypeString() {
return builder.toString();
}

@Override public boolean equals(Object o) {
@Override public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}
Expand Down

0 comments on commit 5759a66

Please sign in to comment.