Github user biglobster commented on a diff in the pull request: https://github.com/apache/spark/pull/14374#discussion_r72580290 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeCreator.scala --- @@ -93,20 +93,45 @@ case class CreateMap(children: Seq[Expression]) extends Expression { if (children.size % 2 != 0) { TypeCheckResult.TypeCheckFailure(s"$prettyName expects a positive even number of arguments.") } else if (keys.map(_.dataType).distinct.length > 1) { - TypeCheckResult.TypeCheckFailure("The given keys of function map should all be the same " + - "type, but they are " + keys.map(_.dataType.simpleString).mkString("[", ", ", "]")) + if (keys.map(_.dataType).forall(_.isInstanceOf[DecimalType])) { + TypeCheckResult.TypeCheckSuccess + } else { + TypeCheckResult.TypeCheckFailure("The given keys of function map should all be the same " + + "type, but they are " + keys.map(_.dataType.simpleString).mkString("[", ", ", "]")) + } } else if (values.map(_.dataType).distinct.length > 1) { - TypeCheckResult.TypeCheckFailure("The given values of function map should all be the same " + - "type, but they are " + values.map(_.dataType.simpleString).mkString("[", ", ", "]")) + if (values.map(_.dataType).forall(_.isInstanceOf[DecimalType])) { + TypeCheckResult.TypeCheckSuccess + } else { + TypeCheckResult.TypeCheckFailure("The given values of function map should all be the " + + "same type, but they are " + values.map(_.dataType.simpleString).mkString("[", ", ", "]")) + } } else { TypeCheckResult.TypeCheckSuccess } } + private def checkDecimalType(colType: Seq[Expression]): DataType = { + val elementType = colType.headOption.map(_.dataType).getOrElse(NullType) + elementType match { + case _ if elementType.isInstanceOf[DecimalType] => + var tighter: DataType = elementType + colType.foreach { child => + if (elementType.asInstanceOf[DecimalType].isTighterThan(child.dataType)) { --- End diff -- thxï¼ï¼ get it
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org