static Integer getColumnSize()

in flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/ArrowDatabaseMetadata.java [1203:1257]


  static Integer getColumnSize(final ArrowType fieldType) {
    // We aren't setting COLUMN_SIZE for ROWID SQL Types, as there's no such Arrow type.
    // We aren't setting COLUMN_SIZE nor DECIMAL_DIGITS for Float/Double as their precision and
    // scale are variable.
    if (fieldType instanceof ArrowType.Decimal) {
      final ArrowType.Decimal thisDecimal = (ArrowType.Decimal) fieldType;
      return thisDecimal.getPrecision();
    } else if (fieldType instanceof ArrowType.Int) {
      final ArrowType.Int thisInt = (ArrowType.Int) fieldType;
      switch (thisInt.getBitWidth()) {
        case Byte.SIZE:
          return COLUMN_SIZE_BYTE;
        case Short.SIZE:
          return COLUMN_SIZE_SHORT;
        case Integer.SIZE:
          return COLUMN_SIZE_INT;
        case Long.SIZE:
          return COLUMN_SIZE_LONG;
        default:
          break;
      }
    } else if (fieldType instanceof ArrowType.Utf8 || fieldType instanceof ArrowType.Binary) {
      return COLUMN_SIZE_VARCHAR_AND_BINARY;
    } else if (fieldType instanceof ArrowType.Timestamp) {
      switch (((ArrowType.Timestamp) fieldType).getUnit()) {
        case SECOND:
          return COLUMN_SIZE_TIMESTAMP_SECONDS;
        case MILLISECOND:
          return COLUMN_SIZE_TIMESTAMP_MILLISECONDS;
        case MICROSECOND:
          return COLUMN_SIZE_TIMESTAMP_MICROSECONDS;
        case NANOSECOND:
          return COLUMN_SIZE_TIMESTAMP_NANOSECONDS;
        default:
          break;
      }
    } else if (fieldType instanceof ArrowType.Time) {
      switch (((ArrowType.Time) fieldType).getUnit()) {
        case SECOND:
          return COLUMN_SIZE_TIME;
        case MILLISECOND:
          return COLUMN_SIZE_TIME_MILLISECONDS;
        case MICROSECOND:
          return COLUMN_SIZE_TIME_MICROSECONDS;
        case NANOSECOND:
          return COLUMN_SIZE_TIME_NANOSECONDS;
        default:
          break;
      }
    } else if (fieldType instanceof ArrowType.Date) {
      return COLUMN_SIZE_DATE;
    }

    return null;
  }