def fromArrowType()

in gluten-arrow/src/main/scala/org/apache/spark/sql/utils/SparkArrowUtil.scala [61:81]


  def fromArrowType(dt: ArrowType): DataType = dt match {
    case ArrowType.Bool.INSTANCE => BooleanType
    case int: ArrowType.Int if int.getIsSigned && int.getBitWidth == 8 => ByteType
    case int: ArrowType.Int if int.getIsSigned && int.getBitWidth == 8 * 2 => ShortType
    case int: ArrowType.Int if int.getIsSigned && int.getBitWidth == 8 * 4 => IntegerType
    case int: ArrowType.Int if int.getIsSigned && int.getBitWidth == 8 * 8 => LongType
    case float: ArrowType.FloatingPoint if float.getPrecision() == FloatingPointPrecision.SINGLE =>
      FloatType
    case float: ArrowType.FloatingPoint if float.getPrecision() == FloatingPointPrecision.DOUBLE =>
      DoubleType
    case ArrowType.Utf8.INSTANCE => StringType
    case ArrowType.Binary.INSTANCE => BinaryType
    case d: ArrowType.Decimal => DecimalType(d.getPrecision, d.getScale)
    case date: ArrowType.Date if date.getUnit == DateUnit.DAY => DateType
    // TODO: Time unit is not handled.
    case _: ArrowType.Timestamp => TimestampType
    case interval: ArrowType.Interval if interval.getUnit == IntervalUnit.YEAR_MONTH =>
      YearMonthIntervalType.DEFAULT
    case ArrowType.Null.INSTANCE => NullType
    case _ => throw new UnsupportedOperationException(s"Unsupported data type: $dt")
  }