amaliujia commented on code in PR #40693:
URL: https://github.com/apache/spark/pull/40693#discussion_r1162212156
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala:
##########
@@ -902,152 +903,191 @@ case class Cast(
}
// LongConverter
- private[this] def castToLong(from: DataType): Any => Any = from match {
- case StringType if ansiEnabled =>
- buildCast[UTF8String](_, v => UTF8StringUtils.toLongExact(v,
getContextOrNull()))
- case StringType =>
- val result = new LongWrapper()
- buildCast[UTF8String](_, s => if (s.toLong(result)) result.value else
null)
- case BooleanType =>
- buildCast[Boolean](_, b => if (b) 1L else 0L)
- case DateType =>
- buildCast[Int](_, d => null)
- case TimestampType =>
- buildCast[Long](_, t => timestampToLong(t))
- case x: NumericType if ansiEnabled =>
- b => x.exactNumeric.asInstanceOf[Numeric[Any]].toLong(b)
- case x: NumericType =>
- b => x.numeric.asInstanceOf[Numeric[Any]].toLong(b)
- case x: DayTimeIntervalType =>
- buildCast[Long](_, i => dayTimeIntervalToLong(i, x.startField,
x.endField))
- case x: YearMonthIntervalType =>
- buildCast[Int](_, i => yearMonthIntervalToInt(i, x.startField,
x.endField).toLong)
+ private[this] def castToLong(from: DataType): Any => Any = {
+ var exactNumeric: Numeric[Any] = null
+ var numeric: Numeric[Any] = null
Review Comment:
I see what you are suggesting.
Then probably we move every of those fields (ordering, fractional, numeric,
exactnumeric, integral, etc.) to the top-level fields.
This probably make PhysicalDataType more bigger as many PhysicalDataTypes
need to throw.
--
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]