Github user viirya commented on a diff in the pull request:
https://github.com/apache/spark/pull/9883#discussion_r45571868
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/misc.scala
---
@@ -45,6 +48,66 @@ case class Md5(child: Expression) extends
UnaryExpression with ImplicitCastInput
}
}
+case class Hash(children: Expression*) extends Expression with
ImplicitCastInputTypes {
+
+ override def inputTypes: Seq[AbstractDataType] = children.map(_.dataType)
+ override def dataType: DataType = IntegerType
+
+ override def nullable: Boolean = children.exists(_.nullable)
+
+ @transient
+ private lazy val extractProjection =
GenerateSafeProjection.generate(children)
+
+ lazy val schema = StructType(children.zipWithIndex.map { case (e, idx) =>
+ StructField(s"_c$idx", e.dataType)
+ })
+ @transient
+ private lazy val encoder = RowEncoder(schema)
+
+ def getProjection: Projection = extractProjection
+ def getEncoder: ExpressionEncoder[Row] = encoder
+
+ override def eval(input: InternalRow): Any = {
+ val internalRow: InternalRow = extractProjection(input)
--- End diff --
We can't directly use the `hashCode` of `InternalRow`. Because in
`InternalRow` we store data as internal types instead of its original types.
---
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]