private static boolean convertibleToDoubleWithCast(Type type) { return type instanceof DecimalType || DoubleType.DOUBLE.equals(type) || RealType.REAL.equals(type) || BigintType.BIGINT.equals(type) || IntegerType.INTEGER.equals(type) || SmallintType.SMALLINT.equals(type) || TinyintType.TINYINT.equals(type) || BooleanType.BOOLEAN.equals(type); } }
private boolean satisfiesCoercion(boolean allowCoercion, Type fromType, TypeSignature toTypeSignature) { if (allowCoercion) { return typeManager.canCoerce(fromType, typeManager.getType(toTypeSignature)); } else { return fromType.getTypeSignature().equals(toTypeSignature); } }
@Override protected Type _deserialize(String value, DeserializationContext context) { return typeManager.getType(parseTypeSignature(value)); } }
protected static SqlDecimal decimal(String decimalString) { DecimalParseResult parseResult = Decimals.parseIncludeLeadingZerosInPrecision(decimalString); BigInteger unscaledValue; if (parseResult.getType().isShort()) { unscaledValue = BigInteger.valueOf((Long) parseResult.getObject()); } else { unscaledValue = Decimals.decodeUnscaledValue((Slice) parseResult.getObject()); } return new SqlDecimal(unscaledValue, parseResult.getType().getPrecision(), parseResult.getType().getScale()); }
@Override protected Object getGreaterValue(Object value) { // time zone doesn't matter for ordering return packDateTimeWithZone(unpackMillisUtc((Long) value) + 10, getTimeZoneKeyForOffset(33)); } }
@Override protected void writeDecimalToBlock(BigDecimal decimal, BlockBuilder blockBuilder) { LONG_DECIMAL_TYPE.writeSlice(blockBuilder, encodeScaledValue(decimal)); }
public static Object getJsonObjectValue(Type valueType, ConnectorSession session, Block block, int position) { Object objectValue = valueType.getObjectValue(session, block, position); if (objectValue instanceof SqlDecimal) { objectValue = ((SqlDecimal) objectValue).toBigDecimal(); } return objectValue; } }
@Override public String toString() { return getTypeSignature().toString(); }
@Override public String getDisplayName() { return getTypeSignature().toString(); }
@Override public Type getParameterizedType(String baseTypeName, List<TypeSignatureParameter> typeParameters) { return getType(new TypeSignature(baseTypeName, typeParameters)); }
public static int computeTruncatedLength(Slice slice, int offset, int length, int maxCodePointCount, boolean isCharType) { if (isCharType) { // truncate the characters and then remove the trailing white spaces return byteCountWithoutTrailingSpace(slice, offset, length, maxCodePointCount); } if (maxCodePointCount >= 0 && length > maxCodePointCount) { return byteCount(slice, offset, length, maxCodePointCount); } return length; }
private static boolean convertibleToDoubleWithCast(Type type) { return type instanceof DecimalType || DoubleType.DOUBLE.equals(type) || RealType.REAL.equals(type) || BigintType.BIGINT.equals(type) || IntegerType.INTEGER.equals(type) || SmallintType.SMALLINT.equals(type) || TinyintType.TINYINT.equals(type) || BooleanType.BOOLEAN.equals(type); } }
@Override protected Type _deserialize(String value, DeserializationContext context) { return typeManager.getType(parseTypeSignature(value)); } }
private boolean satisfiesCoercion(boolean allowCoercion, Type fromType, TypeSignature toTypeSignature) { if (allowCoercion) { return typeManager.canCoerce(fromType, typeManager.getType(toTypeSignature)); } else { return fromType.getTypeSignature().equals(toTypeSignature); } }
@Override protected Object getGreaterValue(Object value) { // time zone doesn't matter for ordering return packDateTimeWithZone(unpackMillisUtc((Long) value) + 10, getTimeZoneKeyForOffset(33)); } }
@Override protected void writeDecimalToBlock(BigDecimal decimal, BlockBuilder blockBuilder) { longDecimalType.writeSlice(blockBuilder, encodeScaledValue(decimal)); }
@Override public Type getParameterizedType(String baseTypeName, List<TypeSignatureParameter> typeParameters) { return getType(new TypeSignature(baseTypeName, typeParameters)); }
public static int byteCountWithoutTrailingSpace(Slice slice, int offset, int length, int codePointCount) { int truncatedLength = byteCount(slice, offset, length, codePointCount); return byteCountWithoutTrailingSpace(slice, offset, truncatedLength); }
@Override protected Type _deserialize(String value, DeserializationContext context) { return typeManager.getType(parseTypeSignature(value)); } }
@Override protected Type _deserialize(String value, DeserializationContext context) { return typeManager.getType(parseTypeSignature(value)); } }