uros-db commented on code in PR #47847:
URL: https://github.com/apache/spark/pull/47847#discussion_r1727207966
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CollationTypeCasts.scala:
##########
@@ -90,6 +90,15 @@ object CollationTypeCasts extends TypeCoercionRule {
val newValues = collateToSingleType(mapCreate.values)
mapCreate.withNewChildren(newKeys.zip(newValues).flatMap(pair =>
Seq(pair._1, pair._2)))
+ case levenshtein: Levenshtein =>
+ val Seq(left, right) = Seq(levenshtein.children.head,
levenshtein.children(1))
+ val Seq(newLeft, newRight) = collateToSingleType(Seq(left, right))
+ if (levenshtein.children.size == 2) {
+ levenshtein.withNewChildren(Seq(newLeft, newRight))
+ } else {
+ levenshtein.withNewChildren(Seq(newLeft, newRight,
levenshtein.children(2)))
Review Comment:
or even maybe try to combine the if/else branches using something like:
`levenshtein.withNewChildren(Seq(newLeft, newRight) ++ rest)`
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CollationTypeCasts.scala:
##########
@@ -90,6 +90,15 @@ object CollationTypeCasts extends TypeCoercionRule {
val newValues = collateToSingleType(mapCreate.values)
mapCreate.withNewChildren(newKeys.zip(newValues).flatMap(pair =>
Seq(pair._1, pair._2)))
+ case levenshtein: Levenshtein =>
+ val Seq(left, right) = Seq(levenshtein.children.head,
levenshtein.children(1))
+ val Seq(newLeft, newRight) = collateToSingleType(Seq(left, right))
+ if (levenshtein.children.size == 2) {
+ levenshtein.withNewChildren(Seq(newLeft, newRight))
+ } else {
+ levenshtein.withNewChildren(Seq(newLeft, newRight,
levenshtein.children(2)))
Review Comment:
or even maybe try to combine the if/else branches using something like:
`levenshtein.withNewChildren(Seq(newLeft, newRight) ++ threshold)`
--
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]