public Type toMetacatType()

in metacat-connector-redshift/src/main/java/com/netflix/metacat/connector/redshift/RedshiftTypeConverter.java [49:110]


    public Type toMetacatType(final String type) {
        // See: https://www.postgresql.org/docs/current/static/datatype.html
        final String lowerType = type.toLowerCase();

        // Split up the possible type: TYPE[(size, magnitude)] EXTRA
        final String[] splitType = this.splitType(lowerType);
        switch (splitType[0]) {
            case "smallint":
            case "int2":
                return BaseType.SMALLINT;
            case "int":
            case "integer":
            case "int4":
                return BaseType.INT;
            case "int8":
            case "bigint":
            case "oid":
                return BaseType.BIGINT;
            case "decimal":
            case "numeric":
                return this.toMetacatDecimalType(splitType);
            case "real":
            case "float4":
                return BaseType.FLOAT;
            case "double precision":
            case "float8":
            case "float":
                return BaseType.DOUBLE;
            case "character varying":
            case "varchar":
            case "nvarchar":
                fixDataSizeIfIncorrect(splitType);
                return this.toMetacatVarcharType(splitType);
            case "text":
            case "name":
                // text is basically alias for VARCHAR(256)
                splitType[1] = DEFAULT_CHARACTER_LENGTH_STRING;
                return this.toMetacatVarcharType(splitType);
            case "character":
            case "char":
            case "nchar":
                fixDataSizeIfIncorrect(splitType);
                return this.toMetacatCharType(splitType);
            case "bpchar":
                // bpchar defaults to fixed length of 256 characters
                splitType[1] = DEFAULT_CHARACTER_LENGTH_STRING;
                return this.toMetacatCharType(splitType);
            case "timestamp":
                return this.toMetacatTimestampType(splitType);
            case "timestampz":
                return BaseType.TIMESTAMP_WITH_TIME_ZONE;
            case "date":
                return BaseType.DATE;
            case "boolean":
            case "bool":
                return BaseType.BOOLEAN;
            default:
                // see: http://docs.aws.amazon.com/redshift/latest/dg/c_unsupported-postgresql-datatypes.html
                log.info("Unhandled or unknown Redshift type {}", splitType[0]);
                return BaseType.UNKNOWN;
        }
    }