in flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/utils/SqlTypes.java [91:164]
public static int getSqlTypeIdFromArrowType(ArrowType arrowType) {
final ArrowType.ArrowTypeID typeID = arrowType.getTypeID();
switch (typeID) {
case Int:
final int bitWidth = ((ArrowType.Int) arrowType).getBitWidth();
switch (bitWidth) {
case 8:
return Types.TINYINT;
case 16:
return Types.SMALLINT;
case 32:
return Types.INTEGER;
case 64:
return Types.BIGINT;
default:
break;
}
break;
case Binary:
return Types.VARBINARY;
case FixedSizeBinary:
return Types.BINARY;
case LargeBinary:
return Types.LONGVARBINARY;
case Utf8:
return Types.VARCHAR;
case LargeUtf8:
return Types.LONGVARCHAR;
case Date:
return Types.DATE;
case Time:
return Types.TIME;
case Timestamp:
String tz = ((ArrowType.Timestamp) arrowType).getTimezone();
if (Strings.isNullOrEmpty(tz)) {
return Types.TIMESTAMP;
} else {
return Types.TIMESTAMP_WITH_TIMEZONE;
}
case Bool:
return Types.BOOLEAN;
case Decimal:
return Types.DECIMAL;
case FloatingPoint:
final FloatingPointPrecision floatingPointPrecision =
((ArrowType.FloatingPoint) arrowType).getPrecision();
switch (floatingPointPrecision) {
case DOUBLE:
return Types.DOUBLE;
case SINGLE:
return Types.FLOAT;
default:
break;
}
break;
case List:
case FixedSizeList:
case LargeList:
return Types.ARRAY;
case Struct:
case Duration:
case Interval:
case Map:
case Union:
return Types.JAVA_OBJECT;
case NONE:
case Null:
return Types.NULL;
default:
break;
}
throw new IllegalArgumentException("Unsupported ArrowType " + arrowType);
}