Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

Commit

Permalink
Cast short type to int32
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILO-HE committed Jul 22, 2022
1 parent b6de407 commit c7db034
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,19 @@ object CodeGeneration {

def getResultType(left: ArrowType, right: ArrowType): ArrowType = {
//TODO(): remove this API
left
// Use left type except that left is int16. If both right & left are int16,
// int32 will be used.
left match {
case intLeft: ArrowType.Int if (intLeft.getBitWidth == 16) =>
right match {
case intRight: ArrowType.Int if (intRight.getBitWidth == 16) =>
new ArrowType.Int(32, true)
case _ =>
right
}
case _ =>
left
}
}

def getResultType(dataType: DataType): ArrowType = {
Expand Down Expand Up @@ -81,6 +93,8 @@ object CodeGeneration {
dataType match {
case t: ArrowType.FloatingPoint =>
s"castFLOAT${4 * dataType.asInstanceOf[ArrowType.FloatingPoint].getPrecision().getFlatbufID()}"
case i: ArrowType.Int if i.getBitWidth == 32 =>
"castINT"
case _ =>
throw new UnsupportedOperationException(s"getCastFuncName(${dataType}) is not supported.")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class ColumnarLiteral(lit: Literal)
throw new UnsupportedOperationException(
s"can't support CalendarIntervalType with microseconds yet")
}
case ShortType =>
new ArrowType.Int(32, true)
case _ =>
CodeGeneration.getResultType(dataType)
}
Expand All @@ -97,12 +99,13 @@ class ColumnarLiteral(lit: Literal)
case _ =>
(TreeBuilder.makeLiteral(value.asInstanceOf[Integer]), resultType)
}
case t: ShortType =>
case _: ShortType =>
value match {
case null =>
(TreeBuilder.makeNull(resultType), resultType)
case _ =>
(TreeBuilder.makeLiteral(value.asInstanceOf[Integer]), resultType)
(TreeBuilder.makeLiteral(new Integer(
value.asInstanceOf[java.lang.Short].toInt)), resultType)
}
case t: LongType =>
value match {
Expand Down

0 comments on commit c7db034

Please sign in to comment.