public static String getJdbcTypeString()

in src/main/java/com/uber/uberscriptquery/jdbc/JdbcUtils.java [200:225]


    public static String getJdbcTypeString(org.apache.spark.sql.types.DataType dataType, boolean isPrimaryKeyOrIndexKey, boolean isText) {
        int maxVarcharLength = isPrimaryKeyOrIndexKey ? 150 : 250;
        String sqlTypeForString = isText ? "TEXT" : String.format("VARCHAR(%s)", maxVarcharLength);
        if (dataType == DataTypes.TimestampType || dataType == DataTypes.DateType) {
            return "DATETIME";
        } else if (dataType == DataTypes.StringType) {
            return sqlTypeForString;
        } else if (dataType == DataTypes.IntegerType) {
            return "INT";
        } else if (dataType == DataTypes.LongType) {
            return "BIGINT";
        } else if (dataType == DataTypes.FloatType) {
            return "FLOAT";
        } else if (dataType == DataTypes.DoubleType) {
            return "DOUBLE";
        } else if (dataType == DataTypes.BooleanType) {
            return "TINYINT";
        } else if (dataType == DataTypes.ByteType) {
            return "SMALLINT";
        } else if (dataType instanceof org.apache.spark.sql.types.DecimalType) {
            org.apache.spark.sql.types.DecimalType decimalType = (org.apache.spark.sql.types.DecimalType) dataType;
            return String.format("DECIMAL(%d,%d)", decimalType.precision(), decimalType.scale());
        } else {
            throw new RuntimeException(String.format("Unsupported property type for JDBC: %s", dataType));
        }
    }