diff --git a/common/workflow-core/src/main/scala/org/apache/texera/amber/util/ArrowUtils.scala b/common/workflow-core/src/main/scala/org/apache/texera/amber/util/ArrowUtils.scala index c4f649e719e..af14ae9acd0 100644 --- a/common/workflow-core/src/main/scala/org/apache/texera/amber/util/ArrowUtils.scala +++ b/common/workflow-core/src/main/scala/org/apache/texera/amber/util/ArrowUtils.scala @@ -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 @@ -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 => diff --git a/common/workflow-core/src/test/scala/org/apache/texera/amber/util/ArrowUtilsSpec.scala b/common/workflow-core/src/test/scala/org/apache/texera/amber/util/ArrowUtilsSpec.scala index 212be040b12..62b10a66864 100644 --- a/common/workflow-core/src/test/scala/org/apache/texera/amber/util/ArrowUtilsSpec.scala +++ b/common/workflow-core/src/test/scala/org/apache/texera/amber/util/ArrowUtilsSpec.scala @@ -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 {