stevomitric commented on code in PR #56199:
URL: https://github.com/apache/spark/pull/56199#discussion_r3332957457
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/literals.scala:
##########
@@ -540,11 +540,15 @@ case class Literal (value: Any, dataType: DataType)
extends LeafExpression {
}
case ByteType | ShortType =>
ExprCode.forNonNullValue(JavaCode.expression(s"($javaType)$value",
dataType))
- case TimestampType | TimestampNTZType | LongType | _:
DayTimeIntervalType | _: TimeType =>
+ case TimestampType | TimestampNTZType | LongType | _:
DayTimeIntervalType =>
Review Comment:
When types framework conf is off this will fallback down to `case _ =>`
which will be `((long) references[idx])` - doesn't compile (references is
Object[]).
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala:
##########
@@ -1689,23 +1689,27 @@ object CodeGenerator extends Logging {
val jt = javaType(dataType)
dataType match {
case udt: UserDefinedType[_] => getValue(input, udt.sqlType, ordinal)
- case _ if isPrimitiveType(jt) =>
s"$input.get${primitiveTypeName(jt)}($ordinal)"
- case _ => PhysicalDataType(dataType) match {
- case _: PhysicalArrayType => s"$input.getArray($ordinal)"
- case PhysicalBinaryType => s"$input.getBinary($ordinal)"
- case _: PhysicalGeographyType => s"$input.getGeography($ordinal)"
- case _: PhysicalGeometryType => s"$input.getGeometry($ordinal)"
- case PhysicalCalendarIntervalType => s"$input.getInterval($ordinal)"
- case PhysicalTimestampNTZNanosType =>
s"$input.getTimestampNTZNanos($ordinal)"
- case PhysicalTimestampLTZNanosType =>
s"$input.getTimestampLTZNanos($ordinal)"
- case t: PhysicalDecimalType => s"$input.getDecimal($ordinal,
${t.precision}, ${t.scale})"
- case _: PhysicalMapType => s"$input.getMap($ordinal)"
- case PhysicalNullType => "null"
- case _: PhysicalStringType => s"$input.getUTF8String($ordinal)"
- case t: PhysicalStructType => s"$input.getStruct($ordinal,
${t.fields.length})"
- case PhysicalVariantType => s"$input.getVariant($ordinal)"
- case _ => s"($jt)$input.get($ordinal, null)"
- }
+ case _ =>
+ TypeOps(dataType).map(_.getCodegenGetter(input, ordinal)).getOrElse {
Review Comment:
Perhaps it might make more sense to split timestamp-nano related types
changes from the abstract framework changes into two PRs.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/literals.scala:
##########
@@ -540,11 +540,15 @@ case class Literal (value: Any, dataType: DataType)
extends LeafExpression {
}
case ByteType | ShortType =>
ExprCode.forNonNullValue(JavaCode.expression(s"($javaType)$value",
dataType))
- case TimestampType | TimestampNTZType | LongType | _:
DayTimeIntervalType | _: TimeType =>
+ case TimestampType | TimestampNTZType | LongType | _:
DayTimeIntervalType =>
toExprCode(s"${value}L")
case _ =>
- val constRef = ctx.addReferenceObj("literal", value, javaType)
- ExprCode.forNonNullValue(JavaCode.global(constRef, dataType))
+ TypeOps(dataType)
Review Comment:
I was unaware types integrated in codegen directly. cc @davidm-db
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]