in metacat-connector-snowflake/src/main/java/com/netflix/metacat/connector/snowflake/SnowflakeTypeConverter.java [126:189]
public String fromMetacatType(final Type type) {
switch (type.getTypeSignature().getBase()) {
case ARRAY:
throw new UnsupportedOperationException("Snowflake doesn't support array types");
case BIGINT:
return "NUMBER(38)";
case BOOLEAN:
return "BOOLEAN";
case CHAR:
if (!(type instanceof CharType)) {
throw new IllegalArgumentException("Expected CHAR type but was " + type.getClass().getName());
}
final CharType charType = (CharType) type;
return "CHAR(" + charType.getLength() + ")";
case DATE:
return "DATE";
case DECIMAL:
if (!(type instanceof DecimalType)) {
throw new IllegalArgumentException("Expected decimal type but was " + type.getClass().getName());
}
final DecimalType decimalType = (DecimalType) type;
return "DECIMAL(" + decimalType.getPrecision() + ", " + decimalType.getScale() + ")";
case DOUBLE:
case FLOAT:
return "DOUBLE PRECISION";
case INT:
return "INT";
case INTERVAL_DAY_TO_SECOND:
throw new UnsupportedOperationException("Snowflake doesn't support interval types");
case INTERVAL_YEAR_TO_MONTH:
throw new UnsupportedOperationException("Snowflake doesn't support interval types");
case JSON:
throw new UnsupportedOperationException("Snowflake doesn't support JSON types");
case MAP:
throw new UnsupportedOperationException("Snowflake doesn't support MAP types");
case ROW:
throw new UnsupportedOperationException("Snowflake doesn't support ROW types");
case SMALLINT:
return "SMALLINT";
case STRING:
return "STRING";
case TIME:
case TIME_WITH_TIME_ZONE:
return "TIME";
case TIMESTAMP:
return "TIMESTAMP";
case TIMESTAMP_WITH_TIME_ZONE:
return "TIMESTAMPTZ";
case TINYINT:
return "SMALLINT";
case UNKNOWN:
throw new IllegalArgumentException("Can't map an unknown type");
case VARBINARY:
return "VARBINARY";
case VARCHAR:
if (!(type instanceof VarcharType)) {
throw new IllegalArgumentException("Expected varchar type but was " + type.getClass().getName());
}
final VarcharType varcharType = (VarcharType) type;
return "VARCHAR(" + varcharType.getLength() + ")";
default:
throw new IllegalArgumentException("Unknown type " + type.getTypeSignature().getBase());
}
}