Remove redundant instanceof in LiteralInterpreter.toExpression
The fact `object` type matches type's java type is asserted earlier.
@@ -52,7 +52,6 @@ import io.airlift.slice.DynamicSliceOutput;
import io.airlift.slice.Slice;
import io.airlift.slice.SliceOutput;
import io.airlift.slice.SliceUtf8;
-import io.airlift.slice.Slices;
import java.util.List;
@@ -171,11 +170,6 @@ public final class LiteralInterpreter
}
if (type instanceof VarcharType) {
- if (object instanceof String) {
- object = Slices.utf8Slice((String) object);
- }
-
- if (object instanceof Slice) {
Slice value = (Slice) object;
int length = SliceUtf8.countCodePoints(value);
@@ -186,9 +180,6 @@ public final class LiteralInterpreter
return new Cast(new StringLiteral(value.toStringUtf8()), type.getDisplayName(), false, true);
}
- throw new IllegalArgumentException("object must be instance of Slice or String when type is VARCHAR");
- }
-
if (type.equals(BOOLEAN)) {
return new BooleanLiteral(object.toString());
}
