MaxGekk commented on a change in pull request #30474:
URL: https://github.com/apache/spark/pull/30474#discussion_r529228577
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolvePartitionSpec.scala
##########
@@ -65,31 +65,8 @@ object ResolvePartitionSpec extends Rule[LogicalPlan] {
conf.resolver)
val partValues = partSchema.map { part =>
- val partValue = normalizedSpec.get(part.name).orNull
- if (partValue == null) {
- null
- } else {
- // TODO: Support other datatypes, such as DateType
- part.dataType match {
- case _: ByteType =>
- partValue.toByte
- case _: ShortType =>
- partValue.toShort
- case _: IntegerType =>
- partValue.toInt
- case _: LongType =>
- partValue.toLong
- case _: FloatType =>
- partValue.toFloat
- case _: DoubleType =>
- partValue.toDouble
- case _: StringType =>
- partValue
- case _ =>
- throw new AnalysisException(
- s"Type ${part.dataType.typeName} is not supported for
partition.")
- }
- }
+ val raw = normalizedSpec.get(part.name).orNull
+ Cast(Literal.create(raw, StringType), part.dataType,
Some(conf.sessionLocalTimeZone)).eval()
Review comment:
I think V1 does the same, see
https://github.com/apache/spark/blob/dfa6fb46f4238792bff6a0201da201be1b42620e/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/interface.scala#L149-L165
Let me extract the code to `PartitioningUtils`, and re-use it in V2.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]