Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/21704#discussion_r202064680
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala
---
@@ -259,8 +270,22 @@ object TypeCoercion {
}
}
- private def haveSameType(exprs: Seq[Expression]): Boolean =
- exprs.map(_.dataType).distinct.length == 1
+ private def haveSameType(exprs: Seq[Expression]): Boolean = {
--- End diff --
This is duplicated with
`ComplexTypeMergingExpression.areInputTypesForMergingEqual`, can we unify them?
We can
1. remove `hasSameType`. Any expression that needs to do this check should
extend `ComplexTypeMergingExpression` and the TypeCoercion rule should call
`areInputTypesForMergingEqual`.
2. remove `areInputTypesForMergingEqual`. `ComplexTypeMergingExpression`
should only define the list of data types that need to be merged, and
TypeCoercion rule should call `hasSameType(e.inputTypesForMerging)`
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]