Github user chenghao-intel commented on a diff in the pull request:
https://github.com/apache/spark/pull/7151#discussion_r33685497
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala
---
@@ -266,16 +266,37 @@ abstract class UnaryExpression extends Expression
with trees.UnaryNode[Expressio
}
/**
+ * An trait that gets mixin to define the expected input types of an
expression.
+ */
+trait ExpectsInputTypes { self: Expression =>
+
+ /**
+ * Expected input types from child expressions. The i-th position in the
returned seq indicates
+ * the type requirement for the i-th child.
+ *
+ * The possible values at each position are:
+ * 1. a specific data type, e.g. LongType, StringType.
+ * 2. a non-leaf data type, e.g. NumericType, IntegralType,
FractionalType.
+ * 3. a list of specific data types, e.g. Seq(StringType, BinaryType).
+ */
+ def inputTypes: Seq[Any]
+
+ override def checkInputDataTypes(): TypeCheckResult = {
+ // We will do the type checking in `HiveTypeCoercion`, so always
returning success here.
+ TypeCheckResult.TypeCheckSuccess
+ }
+}
+
+/**
* Expressions that require a specific `DataType` as input should
implement this trait
* so that the proper type conversions can be performed in the analyzer.
*/
-trait AutoCastInputTypes {
- self: Expression =>
+trait AutoCastInputTypes { self: Expression =>
- def expectedChildTypes: Seq[DataType]
+ def inputTypes: Seq[DataType]
override def checkInputDataTypes(): TypeCheckResult = {
--- End diff --
Leave it unimplemented or throws exception, to force the expression
developer think about what data types can be acceptable.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]