private static Type getCommonSuperTypeForVarchar(VarcharType firstType, VarcharType secondType) { if (firstType.isUnbounded() || secondType.isUnbounded()) { return createUnboundedVarcharType(); } return createVarcharType(Math.max(firstType.getBoundedLength(), secondType.getBoundedLength())); }
public static int getMaxCodePointCount(Type type) { if (isVarcharType(type)) { VarcharType varcharType = (VarcharType) type; return varcharType.isUnbounded() ? -1 : varcharType.getBoundedLength(); } if (isCharType(type)) { return ((CharType) type).getLength(); } if (isVarbinaryType(type)) { return -1; } throw new IllegalArgumentException("Unsupported encoding " + type.getDisplayName()); }
return Optional.of(createCharType(Math.min(CharType.MAX_LENGTH, varcharType.getBoundedLength()))); case JoniRegexpType.NAME: return Optional.of(JONI_REGEXP);
protected String toSqlType(Type type) { if (isVarcharType(type)) { VarcharType varcharType = (VarcharType) type; if (varcharType.isUnbounded()) { return "varchar"; } return "varchar(" + varcharType.getBoundedLength() + ")"; } 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()); }
return ImmutableList.of(new OrcType(OrcTypeKind.STRING)); return ImmutableList.of(new OrcType(OrcTypeKind.VARCHAR, varcharType.getBoundedLength()));
StringLiteral stringLiteral = new StringLiteral(value.toStringUtf8()); if (!varcharType.isUnbounded() && varcharType.getBoundedLength() == SliceUtf8.countCodePoints(value)) { return stringLiteral;