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

[NSE-1024] Support ShortType in ColumnarLiteral #1025

Merged
merged 2 commits into from
Jul 22, 2022
Merged
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 @@ -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 @@ -42,7 +42,7 @@ class ColumnarLiteral(lit: Literal)

def buildCheck(): ArrowType = {
val supportedTypes =
List(StringType, IntegerType, LongType, DoubleType, FloatType, DateType,
List(StringType, ShortType, IntegerType, LongType, DoubleType, FloatType, DateType,
BooleanType, CalendarIntervalType, BinaryType, TimestampType)
if (supportedTypes.indexOf(dataType) == -1 && !dataType.isInstanceOf[DecimalType]) {
// Decimal is supported in ColumnarLiteral
Expand Down 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