private boolean isSupportedType(Type type) { return ImmutableSet.<Type>of(TINYINT, SMALLINT, INTEGER, BIGINT, REAL, DOUBLE, BOOLEAN, DATE, TIMESTAMP, VARBINARY).contains(type) || isVarcharType(type) || type instanceof DecimalType; } }
private static boolean isSupportedType(Type type) { if (isVarcharType(type)) { return true; } if (ImmutableList.of(BIGINT, INTEGER, SMALLINT, TINYINT, BOOLEAN, DOUBLE).contains(type)) { return true; } return false; }
private boolean isSupportedPrimitive(Type type) { return isVarcharType(type) || ImmutableList.of( BigintType.BIGINT, BooleanType.BOOLEAN, DoubleType.DOUBLE, VarbinaryType.VARBINARY).contains(type); }
public static Slice truncateToLength(Slice slice, Type type) { requireNonNull(type, "type is null"); if (!isVarcharType(type)) { throw new IllegalArgumentException("type must be the instance of VarcharType"); } return truncateToLength(slice, VarcharType.class.cast(type)); }
private static boolean isSupportedType(Type type) { if (isVarcharType(type)) { return true; } if (ImmutableList.of(BIGINT, INTEGER, SMALLINT, TINYINT, BOOLEAN, DOUBLE).contains(type)) { return true; } return false; }
private static boolean hasDataSize(Type type) { return isVarcharType(type) || isCharType(type); }
private boolean isSupportedType(Type type) { if (isVarcharType(type)) { return true; } if (ImmutableList.of( BIGINT, INTEGER, SMALLINT, TINYINT, BOOLEAN, DOUBLE ).contains(type)) { return true; } return false; }
return FLOAT; else if (isVarcharType(type)) { return TEXT;
public static Set<ColumnStatisticType> getSupportedColumnStatistics(Type type) { if (type.equals(BOOLEAN)) { return ImmutableSet.of(NUMBER_OF_NON_NULL_VALUES, NUMBER_OF_TRUE_VALUES); } if (isNumericType(type) || type.equals(DATE) || type.equals(TIMESTAMP)) { // TODO #7122 support non-legacy TIMESTAMP return ImmutableSet.of(MIN_VALUE, MAX_VALUE, NUMBER_OF_DISTINCT_VALUES, NUMBER_OF_NON_NULL_VALUES); } if (isVarcharType(type) || isCharType(type)) { // TODO Collect MIN,MAX once it is used by the optimizer return ImmutableSet.of(NUMBER_OF_NON_NULL_VALUES, NUMBER_OF_DISTINCT_VALUES, TOTAL_SIZE_IN_BYTES, MAX_VALUE_SIZE_IN_BYTES); } if (type.equals(VARBINARY)) { return ImmutableSet.of(NUMBER_OF_NON_NULL_VALUES, TOTAL_SIZE_IN_BYTES, MAX_VALUE_SIZE_IN_BYTES); } if (type instanceof ArrayType || type instanceof RowType || type instanceof MapType) { return ImmutableSet.of(); } // Throwing here to make sure this method is updated when a new type is added in Hive connector throw new IllegalArgumentException("Unsupported type: " + type); }
private static Integer charOctetLength(Type type) { if (isVarcharType(type)) { return ((VarcharType) type).getLength(); } if (isCharType(type)) { return ((CharType) type).getLength(); } if (type.equals(VARBINARY)) { return Integer.MAX_VALUE; } return null; }
@Override public Slice getSlice() { String textValue = value.isValueNode() ? value.asText() : value.toString(); Slice slice = utf8Slice(textValue); if (isVarcharType(columnHandle.getType())) { slice = truncateToLength(slice, columnHandle.getType()); } return slice; } }
private Object convertValue(Object value, Type type) { if (value == null) { return null; } if (type == BOOLEAN || type == DATE || isVarcharType(type)) { return value; } if (type == BIGINT) { return ((Number) value).longValue(); } if (type == INTEGER) { return ((Number) value).intValue(); } if (type == DOUBLE) { return ((Number) value).doubleValue(); } throw new IllegalArgumentException("Unhandled type: " + type); } }
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()); }
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()); }
private static boolean isValidPartitionType(Type type) { return type instanceof DecimalType || BOOLEAN.equals(type) || TINYINT.equals(type) || SMALLINT.equals(type) || INTEGER.equals(type) || BIGINT.equals(type) || REAL.equals(type) || DOUBLE.equals(type) || DATE.equals(type) || TIMESTAMP.equals(type) || isVarcharType(type) || isCharType(type); }
if (BOOLEAN.equals(type) || Varchars.isVarcharType(type)) { return value;
if (BOOLEAN.equals(type) || Varchars.isVarcharType(type)) { return value;
@Override protected void readValue(BlockBuilder blockBuilder, Type type) { if (definitionLevel == columnDescriptor.getMaxDefinitionLevel()) { Binary binary = valuesReader.readBytes(); Slice value; if (binary.length() == 0) { value = EMPTY_SLICE; } else { value = wrappedBuffer(binary.getBytes()); } if (isVarcharType(type)) { value = truncateToLength(value, type); } if (isCharType(type)) { value = truncateToLengthAndTrimSpaces(value, type); } type.writeSlice(blockBuilder, value); } else if (isValueNull()) { blockBuilder.appendNull(); } }
return "mediumblob"; if (isVarcharType(type)) { VarcharType varcharType = (VarcharType) type; if (varcharType.isUnbounded()) {
return new SqlDecimal((BigInteger) fieldFromCursor, decimalType.getPrecision(), decimalType.getScale()); if (isVarcharType(type)) { return new String(((Slice) fieldFromCursor).getBytes());