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()); }
return Optional.of(createCharType(Math.min(CharType.MAX_LENGTH, varcharType.getLengthSafe()))); case JoniRegexpType.NAME: return Optional.of(JONI_REGEXP);
return "longtext"; if (varcharType.getLengthSafe() <= 255) { return "tinytext"; if (varcharType.getLengthSafe() <= 65535) { return "text"; if (varcharType.getLengthSafe() <= 16777215) { return "mediumtext";
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()); }
return ImmutableList.of(new OrcType(OrcTypeKind.STRING)); return ImmutableList.of(new OrcType(OrcTypeKind.VARCHAR, varcharType.getLengthSafe()));
StringLiteral stringLiteral = new StringLiteral(value.toStringUtf8()); if (!varcharType.isUnbounded() && varcharType.getLengthSafe() == SliceUtf8.countCodePoints(value)) { return stringLiteral;
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()); }
return "longtext"; if (varcharType.getLengthSafe() <= 255) { return "tinytext"; if (varcharType.getLengthSafe() <= 65535) { return "text"; if (varcharType.getLengthSafe() <= 16777215) { return "mediumtext";
return ImmutableList.of(new OrcType(OrcTypeKind.STRING)); return ImmutableList.of(new OrcType(OrcTypeKind.VARCHAR, varcharType.getLengthSafe()));