@Override public String getDisplayName() { return ARRAY + "(" + elementType.getDisplayName() + ")"; } }
@Override public String getDisplayName() { return "map(" + keyType.getDisplayName() + ", " + valueType.getDisplayName() + ")"; }
private void checkFieldTypeOneOf(FieldType declaredFieldType, String columnName, FieldType... allowedFieldTypes) { if (!Arrays.asList(allowedFieldTypes).contains(declaredFieldType)) { throw new IllegalArgumentException(format( "Wrong dataFormat '%s' specified for column '%s'; %s type implies use of %s", declaredFieldType.name(), columnName, columnType.getDisplayName(), Joiner.on("/").join(allowedFieldTypes))); } }
private void checkFieldTypeOneOf(FieldType declaredFieldType, String columnName, FieldType... allowedFieldTypes) { if (!Arrays.asList(allowedFieldTypes).contains(declaredFieldType)) { throw new IllegalArgumentException(format( "Wrong dataFormat '%s' specified for column '%s'; %s type implies use of %s", declaredFieldType.name(), columnName, columnType.getDisplayName(), Joiner.on("/").join(allowedFieldTypes))); } }
private String formatOutputs(Iterable<Symbol> symbols) { return Joiner.on(", ").join(Iterables.transform(symbols, input -> input + ":" + types.get(input).getDisplayName())); }
private String formatOutputs(Iterable<Symbol> symbols) { return Joiner.on(", ").join(Iterables.transform(symbols, input -> input + ":" + types.get(input).getDisplayName())); }
private String getVarcharValue(Type type, Object value) { if (type instanceof VarcharType) { return ((Slice) value).toStringUtf8(); } if (type instanceof TinyintType || type instanceof SmallintType || type instanceof IntegerType || type instanceof BigintType) { return ((Long) value).toString(); } if (type instanceof BooleanType) { return ((Boolean) value).toString(); } throw new PrestoException(NOT_SUPPORTED, format("Unsupported data type in EXPLAIN (TYPE IO): %s", type.getDisplayName())); }
private String getVarcharValue(Type type, Object value) { if (type instanceof VarcharType) { return ((Slice) value).toStringUtf8(); } if (type instanceof TinyintType || type instanceof SmallintType || type instanceof IntegerType || type instanceof BigintType) { return ((Long) value).toString(); } throw new PrestoException(NOT_SUPPORTED, format("Unsupported data type in EXPLAIN (TYPE IO): %s", type.getDisplayName())); }
private static void assertColumnSpec(ResultSet rs, int jdbcType, Long columnSize, Long numPrecRadix, Long decimalDigits, Long charOctetLength, Type type) throws SQLException { String message = " of " + type.getDisplayName() + ": "; assertTrue(rs.next()); assertEquals(rs.getObject("DATA_TYPE"), (long) jdbcType, "DATA_TYPE" + message); assertEquals(rs.getObject("COLUMN_SIZE"), columnSize, "COLUMN_SIZE" + message); assertEquals(rs.getObject("NUM_PREC_RADIX"), numPrecRadix, "NUM_PREC_RADIX" + message); assertEquals(rs.getObject("DECIMAL_DIGITS"), decimalDigits, "DECIMAL_DIGITS" + message); assertEquals(rs.getObject("CHAR_OCTET_LENGTH"), charOctetLength, "CHAR_OCTET_LENGTH" + message); }
public static JsonFieldDecoder throwUnsupportedColumnType(DecoderColumnHandle column) { if (column.getDataFormat() == null) { throw new IllegalArgumentException(format("unsupported column type '%s' for column '%s'", column.getType().getDisplayName(), column.getName())); } throw new IllegalArgumentException(format("unsupported column type '%s' for column '%s' with data format '%s'", column.getType(), column.getName(), column.getDataFormat())); } }
public static JsonFieldDecoder throwUnsupportedColumnType(DecoderColumnHandle column) { if (column.getDataFormat() == null) { throw new IllegalArgumentException(format("unsupported column type '%s' for column '%s'", column.getType().getDisplayName(), column.getName())); } throw new IllegalArgumentException(format("unsupported column type '%s' for column '%s' with data format '%s'", column.getType(), column.getName(), column.getDataFormat())); } }
private static void assertColumnSpec(ResultSet rs, int jdbcType, Long columnSize, Long numPrecRadix, Long decimalDigits, Long charOctetLength, Type type) throws SQLException { String message = " of " + type.getDisplayName() + ": "; assertTrue(rs.next()); assertEquals(rs.getObject("DATA_TYPE"), (long) jdbcType, "DATA_TYPE" + message); assertEquals(rs.getObject("COLUMN_SIZE"), columnSize, "COLUMN_SIZE" + message); assertEquals(rs.getObject("NUM_PREC_RADIX"), numPrecRadix, "NUM_PREC_RADIX" + message); assertEquals(rs.getObject("DECIMAL_DIGITS"), decimalDigits, "DECIMAL_DIGITS" + message); assertEquals(rs.getObject("CHAR_OCTET_LENGTH"), charOctetLength, "CHAR_OCTET_LENGTH" + message); }
private static HashFunction getHashFunction(Type type) { if (type.equals(BIGINT)) { return bigintHashFunction(); } if (type.equals(INTEGER)) { return intHashFunction(); } if (isVarcharType(type)) { return varcharHashFunction(); } throw new PrestoException(NOT_SUPPORTED, "Bucketing is supported for bigint, integer and varchar, not " + type.getDisplayName()); }
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()); }
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()); }
@Test public void testDisplayName() { TypeManager typeManager = new TypeRegistry(); Type function = typeManager.getType(TypeSignature.parseTypeSignature("function<row(field double),bigint>")); assertEquals(function.getDisplayName(), "function<row(field double),bigint>"); } }
@Test public void testDisplayName() { TypeManager typeManager = new TypeRegistry(); Type function = typeManager.getType(TypeSignature.parseTypeSignature("function<row(field double),bigint>")); assertEquals(function.getDisplayName(), "function<row(field double),bigint>"); } }
private Object getPrestoObject(TpchColumn<E> column, Type type) { if (type.getJavaType() == long.class) { return getLong(column); } else if (type.getJavaType() == double.class) { return getDouble(column); } else if (type.getJavaType() == Slice.class) { return getSlice(column); } else { throw new PrestoException(NOT_SUPPORTED, format("Unsupported column type %s", type.getDisplayName())); } }
@TypeParameter("T") @SqlType(StandardTypes.VARCHAR) public static Slice typeof( @TypeParameter("T") Type type, @SqlNullable @SqlType("T") Object value) { return utf8Slice(type.getDisplayName()); }
@TypeParameter("T") @SqlType(StandardTypes.VARCHAR) public static Slice typeof( @TypeParameter("T") Type type, @SqlNullable @SqlType("T") Object value) { return utf8Slice(type.getDisplayName()); }