Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,13 @@ object ArrowUtils extends LazyLogging {
case 16 | 32 =>
AttributeType.INTEGER

case 64 | _ =>
case 64 =>
AttributeType.LONG

case other =>
throw new AttributeTypeUtils.AttributeTypeException(
s"Unsupported Int bit width: $other"
)
}
case _: ArrowType.Bool =>
AttributeType.BOOLEAN
Expand Down Expand Up @@ -187,10 +192,15 @@ object ArrowUtils extends LazyLogging {
.asInstanceOf[IntVector]
.setSafe(index, !isNull, if (isNull) 0 else value.asInstanceOf[Int])

case 64 | _ =>
case 64 =>
vector
.asInstanceOf[BigIntVector]
.setSafe(index, !isNull, if (isNull) 0 else value.asInstanceOf[Long])

case other =>
throw new AttributeTypeUtils.AttributeTypeException(
s"Unsupported Int bit width: $other"
)
}

case _: ArrowType.Bool =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ class ArrowUtilsSpec extends AnyFlatSpec with Matchers {
ArrowUtils.toAttributeType(new ArrowType.Int(64, true)) shouldBe AttributeType.LONG
}

it should "map non-standard Int bit-widths to LONG (current behavior)" in {
// Pin: the source code's match is `case 16 | 32 => INTEGER` then
// `case 64 | _ => LONG`. The trailing `_` makes the second arm a
// catch-all, so Int(8), Int(128) and any other width all surface as
// LONG. A future fix that distinguishes those widths will deliberately
// break this spec.
ArrowUtils.toAttributeType(new ArrowType.Int(8, true)) shouldBe AttributeType.LONG
ArrowUtils.toAttributeType(new ArrowType.Int(128, true)) shouldBe AttributeType.LONG
it should "throw AttributeTypeException for non-standard Int bit-widths" in {
// Only 16/32 (INTEGER) and 64 (LONG) are supported. Other widths used to
// be silently coerced to LONG by a `case 64 | _` catch-all; they now
// raise rather than masquerade as Int64.
assertThrows[AttributeTypeException] {
ArrowUtils.toAttributeType(new ArrowType.Int(8, true))
}
assertThrows[AttributeTypeException] {
ArrowUtils.toAttributeType(new ArrowType.Int(128, true))
}
}

it should "map Bool to BOOLEAN" in {
Expand Down
Loading