public int getLengthSafe() { if (isUnbounded()) { throw new IllegalStateException("Cannot get size of unbounded VARCHAR."); } return length; }
private static Type getCommonSuperTypeForVarchar(VarcharType firstType, VarcharType secondType) { if (firstType.isUnbounded() || secondType.isUnbounded()) { return createUnboundedVarcharType(); } return createVarcharType(Math.max(firstType.getLength(), secondType.getLength())); }
public static int getMaxCodePointCount(Type type) { if (isVarcharType(type)) { VarcharType varcharType = (VarcharType) type; return varcharType.isUnbounded() ? -1 : varcharType.getLengthSafe(); } if (isCharType(type)) { return ((CharType) type).getLength(); } if (isVarbinaryType(type)) { return -1; } throw new IllegalArgumentException("Unsupported encoding " + type.getDisplayName()); }
if (varcharType.isUnbounded()) { return Optional.of(CharType.createCharType(CharType.MAX_LENGTH));
protected String toSqlType(Type type) { if (isVarcharType(type)) { VarcharType varcharType = (VarcharType) type; if (varcharType.isUnbounded()) { return "varchar"; } return "varchar(" + varcharType.getLengthSafe() + ")"; } if (type instanceof CharType) { if (((CharType) type).getLength() == CharType.MAX_LENGTH) { return "char"; } return "char(" + ((CharType) type).getLength() + ")"; } if (type instanceof DecimalType) { return format("decimal(%s, %s)", ((DecimalType) type).getPrecision(), ((DecimalType) type).getScale()); } String sqlType = SQL_TYPES.get(type); if (sqlType != null) { return sqlType; } throw new PrestoException(NOT_SUPPORTED, "Unsupported column type: " + type.getDisplayName()); }
if (varcharType.isUnbounded()) { return ImmutableList.of(new OrcType(OrcTypeKind.STRING));
StringLiteral stringLiteral = new StringLiteral(value.toStringUtf8()); if (!varcharType.isUnbounded() && varcharType.getLengthSafe() == SliceUtf8.countCodePoints(value)) { return stringLiteral;
if (varcharType.isUnbounded()) { return "longtext";
public int getLengthSafe() { if (isUnbounded()) { throw new IllegalStateException("Cannot get size of unbounded VARCHAR."); } return length; }
public static int getMaxCodePointCount(Type type) { if (isVarcharType(type)) { VarcharType varcharType = (VarcharType) type; return varcharType.isUnbounded() ? -1 : varcharType.getLengthSafe(); } if (isCharType(type)) { return ((CharType) type).getLength(); } if (isVarbinaryType(type)) { return -1; } throw new IllegalArgumentException("Unsupported encoding " + type.getDisplayName()); }
if (varcharType.isUnbounded()) { return ImmutableList.of(new OrcType(OrcTypeKind.STRING));
if (varcharType.isUnbounded()) { return "longtext";