use of io.prestosql.spi.type.TimeWithTimeZoneType in project hetu-core by openlookeng.
the class TestTypeUtil method testParseType.
@Test
public void testParseType() {
Type type = parseType(typeManager, "bigint");
assertTrue(type instanceof BigintType);
type = parseType(typeManager, "integer");
assertTrue(type instanceof IntegerType);
type = parseType(typeManager, "smallint");
assertTrue(type instanceof SmallintType);
type = parseType(typeManager, "boolean");
assertTrue(type instanceof BooleanType);
type = parseType(typeManager, "date");
assertTrue(type instanceof DateType);
type = parseType(typeManager, "real");
assertTrue(type instanceof RealType);
type = parseType(typeManager, "double");
assertTrue(type instanceof DoubleType);
type = parseType(typeManager, "HyperLogLog");
assertTrue(type instanceof HyperLogLogType);
type = parseType(typeManager, "P4HyperLogLog");
assertTrue(type instanceof P4HyperLogLogType);
type = parseType(typeManager, "timestamp");
assertTrue(type instanceof TimestampType);
type = parseType(typeManager, "timestamp with time zone");
assertTrue(type instanceof TimestampWithTimeZoneType);
type = parseType(typeManager, "time");
assertTrue(type instanceof TimeType);
type = parseType(typeManager, "time with time zone");
assertTrue(type instanceof TimeWithTimeZoneType);
type = parseType(typeManager, "varbinary");
assertTrue(type instanceof VarbinaryType);
type = parseType(typeManager, "unknown");
assertTrue(type instanceof UnknownType);
}
use of io.prestosql.spi.type.TimeWithTimeZoneType in project TiBigData by tidb-incubator.
the class TypeHelpers method toSqlString.
public static String toSqlString(Type type) {
if (type instanceof TimeWithTimeZoneType || type instanceof TimestampWithTimeZoneType) {
throw new PrestoException(NOT_SUPPORTED, "Unsupported column type: " + type.getDisplayName());
}
if (type instanceof TimestampType) {
return format("timestamp(%s)", ((TimestampType) type).getPrecision());
}
if (type instanceof VarcharType) {
VarcharType varcharType = (VarcharType) type;
if (varcharType.isUnbounded()) {
return "longtext";
}
Integer length = varcharType.getLength().orElseThrow(IllegalStateException::new);
if (length <= 255) {
return "tinytext";
}
if (length <= 65535) {
return "text";
}
if (length <= 16777215) {
return "mediumtext";
}
return "longtext";
}
if (type instanceof CharType) {
int length = ((CharType) type).getLength();
if (length <= 255) {
return "char(" + length + ")";
}
return "text";
}
if (type instanceof DecimalType) {
return format("decimal(%s, %s)", ((DecimalType) type).getPrecision(), ((DecimalType) type).getScale());
}
if (type instanceof TimeType) {
return format("time(%s)", ((TimeType) type).getPrecision());
}
String sqlType = SQL_TYPES.get(type);
if (sqlType != null) {
return sqlType;
}
return type.getDisplayName();
}
Aggregations